DBeaver UI Thread vs. JDBC Connection Pool: How Does Concurrent Query Execution Affect Latency?
0 reputation · 31 Jan 2022, 07:25 UTC
0 reputation · 31 Jan 2022, 07:25 UTC
When multiple SQL statements are submitted simultaneously in DBeaver, the single UI thread becomes a bottleneck while the underlying JDBC connection pool may reach its maximum size, causing increased latency. The modal 'Execute SQL' dialog serializes executions, and large result sets can be fully buffered, further amplifying delay. How does UI thread contention interact with connection pool saturation under concurrent client requests? What configuration adjustments could reduce this latency without changing driver defaults? Is there a reliable method to measure UI thread impact versus driver pool limits in DBeaver?
In DBeaver the UI thread runs the SWT event loop; when multiple SQL statements are issued, the thread serializes the submission and result‑set rendering. If the underlying JDBC connection is limited to a single physical connection per session, each statement must wait for the previous one to finish, causing queueing at the driver level. Thus UI thread contention and connection‑slot saturation compound latency.
To isolate the two sources, capture a thread dump (jstack or JFR) while running N concurrent queries and compare the state of the UI thread against worker threads blocked on JDBC calls. Then measure end‑to‑end latency for a single query versus the same N queries executed concurrently, first with default fetch settings and then with fetch‑on‑demand enabled. The delta reveals whether UI rendering or connection‑slot queuing dominates.
Please provide the DBeaver edition and version (Community or Enterprise, e.g., 22.2) so we can confirm whether a shared connection pool exists and tailor the recommendation.
Use comments to ask for clarification. Post a solution as an answer.
5,790 reputation · 31 Jan 2022, 15:45 UTC
DBeaver 23.x+ includes an "Execute in separate thread" toggle in the SQL editor toolbar (not the modal Ctrl+Enter dialog). When enabled, the statement runs on a worker thread and only the first result page plus metadata are posted back to the SWT UI thread, which decouples execution latency from UI freeze time. However, the modal "Execute SQL" dialog remains single-threaded per editor instance, so concurrent Ctrl+Enter executions still serialize on the UI thread.
To isolate the two contention points: open two editor tabs on the same DataSource, run a long query (e.g., SELECT pg_sleep(5)) in each simultaneously, then capture a thread dump (jcmd <pid> Thread.print) while monitoring the connection pool metrics in Database Navigator → Properties → Connection pool. Pool exhaustion shows threads parked in HikariPool.getConnection(); UI contention shows the SWT event thread in ResultSet.next() or TableViewer.refresh(). This distinguishes driver pool saturation from SWT event-loop blocking without changing driver defaults.