ClickHouse / ClickHouse/clickhouse-java

Potential performance issue with SQL parsing in jdbc-v2

オープン
#2,585 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
jdbc-v2 performance v2-feedback
主要言語
Java
スター
1.6k
フォーク
636
平均マージ
2日 23時間
マージ済み PR(30日)
29

説明

Reporting against v.0.9.1. We are using ClickHouse JDBC via Hibernate - our code is calling createNativeQuery a lot - which means creating (and throwing away) a great number of PreparedStatements. As a result we're seeing in close to 6% of CPU time being spent in the driver's statement parsing with production loads (as evaluated with asprof), more specifically in the method org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState.

While I'm aware that this is partly a problem of our usage pattern (PreparedStatements should be cached, which is what we're going to address next at our end), we did not have this issue with the old version (0.2.6) of the driver. In short, the SQL parsing has become slow(er).

I'm writing this to alert you in case no performance benchmarks were performed for that area of code.

I'm also wondering why ANTLR is at all necessary in the driver - I'd assume the actual 'heavyweight' parsing to detect syntax errors and the like is done on the server anyhow, so why have such overheads in the client? But this is likely a deeper design issue not fixable by profiling...

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

レポートでは、jdbc-v2 におけるホットメソッドとして org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState が特定されています。まず、ドライバーのバージョン 0.9.1 と 0.2.6 に対して、createNativeQuery と PreparedStatement のパースを繰り返すケースを再現するか、ベンチマークしてください。完了とするには、リグレッションの確認と、パースまたは設計の変更についての合意が必要ですが、issue にはソースファイルもテストも記載されていません。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
clickhouse, java
領域
databases, performance
issue の種類
バグ
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。