When optimizing an SQL query I stumbled into a situation where a faster query translated into slower overall execution on the Java side. Java 8 with Oracle JDBC 19.3.0.0 was talking to a high‑performance Oracle Database (19c Enterprise Edition; also tested on 18c SE2). The result set had about 140 columns, including 2 CLOB columns that requirements did not allow to split into multiple rows. Because of VPN and Zscaler, I used a higher fetchSize (around 1000), as the default fetch size caused up to 60× slowdown from network overhead.
Before optimization, most of the time was spent executing the SQL on the database. After optimization, the SQL itself was clearly faster, but end‑to‑end execution in the Java application became much slower, up to about 30× slower compared to running the same SQL in SQL Developer. Profiling showed that 98% CPU usage was inside Oracle JDBC internals, specifically PhysicalConnection.removeFromTemporaryLobs.