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
addBatch method cause Java heap memory char array grows too fast #1873
duplicatejdbcModule: the JDBC driver (jdbc-v2; with legacy: the v1 driver)performancequeriesArea: how the client builds and runs statements (parameters, quoting, batches)question
The scenario involves a large number of calls to the addBatch method, Then use jmap to view heap memory,has lots of char[],although they are all unreachable objects that can be GC dropped.But it will lead to frequent GC and high CPU usage. How to solve it
Recommendation: Close — duplicate of #3332 #3332 is the planned work for the same SQL-text batch allocations in jdbc-v2, with the code path. This report adds no other case.
Workaround: For a simple INSERT INTO t VALUES (?, ?), the beta property beta.row_binary_for_simple_insert=true sends RowBinary: 177 + 24 B/row in the same run.
Analysis: The report used 0.2.6 and 0.7.0, before jdbc-v2 became the default driver (0.8.0). jdbc-v2 on main also builds the batch as SQL text: each set* call makes a String (encodeObject, PreparedStatementImpl.java:764), addBatch copies the VALUES tuple of the row into a new StringBuilder (PreparedStatementImpl.java:322-330), and executeBatch joins all tuples into one more StringBuilder and String (PreparedStatementImpl.java:368-377).
duplicatejdbcModule: the JDBC driver (jdbc-v2; with legacy: the v1 driver)performancequeriesArea: how the client builds and runs statements (parameters, quoting, batches)question
Activity
chernser commentedon Oct 21, 2024
Hi @wangbing505
wangbing505 commentedon Oct 23, 2024
Hi @chernser
chernser commentedon Oct 23, 2024
@wangbing505
Please let me know how the update goes. Thanks!
wangbing505 commentedon Oct 24, 2024
@chernser
Thank you for your answer,I will try using them and synchronize the results
chernser commentedon Nov 4, 2024
@wangbing505 as the issue solved?
wangbing505 commentedon Nov 5, 2024
@chernser hello, I have been delayed by other things and will try it next week
wangbing505 commentedon Nov 7, 2024
@chernser Thank you, I tried it, Char [] has decreased,But there are other memory uses as well,maybe it's not a problem with the client anymore
chernser commentedon Jan 9, 2025
Need to verify how jdbc-v2 handles it.
chernser commentedon Nov 14, 2025
We might need to stream big SQL requests like we do with text formats.
Will prioritize this work.
polyglotAI-bot commentedon Nov 28, 2026
Recommendation: Close — duplicate of #3332
#3332 is the planned work for the same SQL-text batch allocations in jdbc-v2, with the code path. This report adds no other case.
main: Reproduced on main — a batch of 100,000 rows allocates 292 B/row inset*+addBatchand 160 B/row inexecuteBatch.set*calls.INSERT INTO t VALUES (?, ?), the beta propertybeta.row_binary_for_simple_insert=truesends RowBinary: 177 + 24 B/row in the same run.Analysis: The report used 0.2.6 and 0.7.0, before jdbc-v2 became the default driver (0.8.0). jdbc-v2 on
mainalso builds the batch as SQL text: eachset*call makes aString(encodeObject,PreparedStatementImpl.java:764),addBatchcopies the VALUES tuple of the row into a newStringBuilder(PreparedStatementImpl.java:322-330), andexecuteBatchjoins all tuples into one moreStringBuilderandString(PreparedStatementImpl.java:368-377).Reproduction: complete program and output
Output on
main(8480ca001), ClickHouse 26.11.4.11:Automated triage by Polyglot AI. A maintainer makes the final decision.