You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[performance][jdbc] Insert operation when RowBinary not available #3332
jdbcModule: the JDBC driver (jdbc-v2; with legacy: the v1 driver)performanceplanned_workWork that is planned for nearest release. Good to takequeriesArea: how the client builds and runs statements (parameters, quoting, batches)
The main pain point in V1 and V2 is wiring big batches when RowBinary insert cannot be used automatically.
However many parts of this process can be optimized:
Recommendation: Keep open — implementation needed
Planned work of epic #3324. The run on main shows where a batch without RowBinary allocates: about 13 bytes for each character of SQL text in set* + addBatch, and about 7 more in executeBatch.
Status on main: Reproduced on main — 100,000 rows of (Int64, String) make 2.69 M characters of SQL; set* + addBatch allocate 351 B/row and executeBatch 182 B/row (RowBinary writer: 163 B + 28 B).
Breaking change: No — can be done without a break.
Analysis: Each set* call makes a SQL text String (encodeObject, PreparedStatementImpl.java:764-862), and addBatch copies the VALUES tuple of the row into a new StringBuilder (PreparedStatementImpl.java:322-330). executeBatch appends all tuples to one more StringBuilder and makes a String of it (PreparedStatementImpl.java:368-377), JDBC escape processing copies the text again (StatementImpl.java:101-107, called at StatementImpl.java:407), and the HTTP layer copies it to a byte[] (HttpAPIClientHelper.java:663). The RowBinary writer runs only with beta.row_binary_for_simple_insert=true and one VALUES list (ConnectionImpl.java:460-480).
Reproduction: complete program and output
Allocations of the calling thread (ThreadMXBean), after a warm-up run of the same batch.
jdbcModule: the JDBC driver (jdbc-v2; with legacy: the v1 driver)performanceplanned_workWork that is planned for nearest release. Good to takequeriesArea: how the client builds and runs statements (parameters, quoting, batches)
Activity
polyglotAI-bot commentedon Nov 27, 2026
Recommendation: Keep open — implementation needed
Planned work of epic #3324. The run on
mainshows where a batch without RowBinary allocates: about 13 bytes for each character of SQL text inset*+addBatch, and about 7 more inexecuteBatch.main: Reproduced on main — 100,000 rows of (Int64, String) make 2.69 M characters of SQL;set*+addBatchallocate 351 B/row andexecuteBatch182 B/row (RowBinary writer: 163 B + 28 B).set*andaddBatchcode. Related: addBatch method cause Java heap memory char array grows too fast #1873 — a user report of heap churn from manyaddBatchcalls. Related: [jdbc-v2] Make Insert with binary default for simple #3328 — makes the RowBinary writer the default for simple inserts.Analysis: Each
set*call makes a SQL textString(encodeObject,PreparedStatementImpl.java:764-862), andaddBatchcopies the VALUES tuple of the row into a newStringBuilder(PreparedStatementImpl.java:322-330).executeBatchappends all tuples to one moreStringBuilderand makes aStringof it (PreparedStatementImpl.java:368-377), JDBC escape processing copies the text again (StatementImpl.java:101-107, called atStatementImpl.java:407), and the HTTP layer copies it to abyte[](HttpAPIClientHelper.java:663). The RowBinary writer runs only withbeta.row_binary_for_simple_insert=trueand one VALUES list (ConnectionImpl.java:460-480).Reproduction: complete program and output
Allocations of the calling thread (
ThreadMXBean), after a warm-up run of the same batch.Output on
main(8480ca001), ClickHouse 26.11.2.4:Automated triage by Polyglot AI. A maintainer makes the final decision.