-
Notifications
You must be signed in to change notification settings - Fork 543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Position of SETTINGS matters for configuration and batching #1152
Comments
Further testing with this shows following behaviour for 100k records inserted, with 1000 records per batch 1st version of the code
inserts it in 1m 22secs 2nd version of the code
in 1s 600ms. !!! so much faster This means 1st version of the code is correct but the question is
Also parser should probably warn/stop if SETTING is used in the wrong place. Even better if it would not matter at all. For reference call executed is
|
Hi @ivenhov, thanks for the reporting and sorry for the confusing results. It's caused by the outdated SQL parser, which expects SETTINGS expression at the end of the insert statement but it should really before VALUES expression :< A few more comments for you to consider:
Update: the parsing issue was caused by breaking change on server side ClickHouse/ClickHouse#35883. |
Thanks for prompt reply.
|
Hi
I'm using JDBC java client v0.3.2-patch11 in spring-boot application.
I'm trying to enable async_insert which I have mixed results with
Testing with a single inserts at the moment, inserting as quickly as possible.
If during my insert I do
I can see that on the server disk space does not grow rapidly and number of parts created is under control considering that I'm not batching. This means the setting is working. It also matches documentation example
https://clickhouse.com/docs/en/cloud/bestpractices/asynchronous-inserts/
However, if I use
then I can see disk usage growing quickly eventually leading to out of disk space.
This means setting is not working.
Why is the position of Settings relevant?
I discovered 2nd version not working one when I was trying to do batching 1000 values per insert.
With that version batching is extremely quick, much faster than with the 1st version so I would like to use that if possible.
I think batching does not work at all in the 1st version .
It may have something to do with parsing broken due to SETTING inserted.
Constructor of SqlBasedPreparedStatement seems to bypass the
https://github.com/ClickHouse/clickhouse-jdbc/blob/f285b73d45597e29cf36dff4daf4cb4f9f53453a/clickhouse-jdbc/src/main/java/com/clickhouse/jdbc/internal/SqlBasedPreparedStatement.java#L78
due to parsedStmt.hasValues() returning false
The same In ClickHouseConnectionImpl
https://github.com/ClickHouse/clickhouse-jdbc/blob/f285b73d45597e29cf36dff4daf4cb4f9f53453a/clickhouse-jdbc/src/main/java/com/clickhouse/jdbc/internal/ClickHouseConnectionImpl.java#L705
it skips this section due to
parsedStmt.hasValues()
returning false.As it stands I cannot reliably configure inserts to have decent performance and avoid rapid parts growth and at the same time benefit from bulk inserts.
Any help with this would be appreciated.
The text was updated successfully, but these errors were encountered: