ClickHouse / ClickHouse/clickhouse-java

Batch Insert r2dbc

Đang mở
#1,802 5 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug r2dbc
Ngôn ngữ chính
Java
Star
1.6k
Fork
636
Merge trung bình
2 ngày 23 giờ
Pull request đã merge (30 ngày)
29

Mô tả

Looks like bulk inserts are inserting 1 by 1 and not in batches.

I have created the following table:

```
CREATE TABLE IF NOT EXISTS test
(
`a` Int16,
`b` Int16,
`created` DateTime
)
ENGINE = MergeTree()
PARTITION BY (toYYYYMM(created))
ORDER BY (created)
TTL created + INTERVAL 13 MONTH;
```

If I try to do the following:

```
public Mono saveAll(){
return Mono.from(connectionFactory.create())
.flatMapMany(conn -> execute(conn)).then();
}

private Publisher execute(Connection conn) {
return conn.createStatement("insert into test values (:a, :b, :created)")
.bind("a",1)
.bind("b", 2)
.bind("created", LocalDateTime.now())
.add()
.bind("a",5)
.bind("b", 6)
.bind("created", LocalDateTime.now())
.execute();
}
```
When checking the logs, I can see that 2 connections are established and inserts are run independently so it is not acting as a batch insert.

```
2024-09-02T10:43:28.253Z DEBUG 49005 --- [ckHouseWorker-1] com.clickhouse.client.AbstractClient : Connection established: com.clickhouse.client.http.HttpUrlConnectionImpl@1f010075
2024-09-02T10:43:28.253Z DEBUG 49005 --- [ckHouseWorker-1] c.c.client.http.ClickHouseHttpClient : Query: insert into `default`.test values (1, 2, 1725273808)
2024-09-02T10:43:28.254Z DEBUG 49005 --- [ckHouseWorker-2] com.clickhouse.client.AbstractClient : Connection established: com.clickhouse.client.http.HttpUrlConnectionImpl@35e8f1b6
2024-09-02T10:43:28.254Z DEBUG 49005 --- [ckHouseWorker-2] c.c.client.http.ClickHouseHttpClient : Query: insert into `default`.test values (5, 6, 1725273808)
```

Am I doing something wrong or is this the intended behaviour?

I have also tried using this approach but same behaviour

```
return conn.createBatch()
.add("insert into test values (1, 2, '2024-01-17 00:00:00')")
.add("insert into test values (5, 6, '2024-01-17 00:00:00')")
.execute();
```

I am using clickhouse-r2dbc version 0.6.4.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Tái hiện ví dụ với clickhouse-r2dbc 0.6.4, bắt đầu từ các entry point Connection.createStatement(...).add() và Connection.createBatch() được hiển thị trong issue. So sánh hành vi của chúng với các insert độc lập được ghi log và xác định liệu các ngữ nghĩa quan sát được có phải là chủ đích hay không. Được coi là hoàn tất khi hành vi của batch đã được xác lập và issue được giải quyết thông qua thay đổi driver phù hợp hoặc hành vi được tài liệu hóa.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
java
Lĩnh vực
databases
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.