Message-ID: From: "dreis2211 (@dreis2211)" To: "pgjdbc/pgjdbc" Date: Tue, 16 Dec 2025 16:18:48 +0000 Subject: [pgjdbc/pgjdbc] issue #3894: Performance regression caused by keeping QUERY_EXECUTE_AS_SIMPLE flag List-Id: X-GitHub-Author-Id: 6304496 X-GitHub-Author-Login: dreis2211 X-GitHub-Issue: 3894 X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-State: open X-GitHub-Type: issue X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/issues/3894 Content-Type: text/plain; charset=utf-8 Hi, I found that after upgrading a Spring-Boot project the particular test suite and certain specific database heavy tests were 2-4 times slower than before. Running a single of those DB heavy tests via Gradle yields this: **Before** ``` BUILD SUCCESSFUL in 3m 38s ``` **After** ``` BUILD SUCCESSFUL in 12m 57s ``` I could trace this back to an update from the postgresql driver from version [42.7.6](https://github.com/pgjdbc/pgjdbc/releases/tag/REL42.7.6) to [42.7.7](https://github.com/pgjdbc/pgjdbc/releases/tag/REL42.7.7). As there are not many changes that could be responsible I looked at the following: - https://github.com/pgjdbc/pgjdbc/commit/cb10dce086845b300f67125a7f33d59cc824c3d8 Particularly, the removal of the following case block ``` case EXTENDED: return flags & ~QUERY_EXECUTE_AS_SIMPLE; ``` When reintroducing this and building a local snapshot, the tests run fast again. I'm not deep enough into the pgjdbc driver to make any call of why that is, but it has a relatively severe impact on us. Briefly looking into things, I wonder if more things than wanted reach "QueryExecutorImpl::sendSimpleQuery" now. At least logging reveals more activity there ``` .... FE=> SimpleQuery(query="SET application_name = 'PostgreSQL JDBC Driver'") FE=> SimpleQuery(query="") FE=> SimpleQuery(query="BEGIN") FE=> SimpleQuery(query="BEGIN") FE=> SimpleQuery(query="BEGIN") FE=> SimpleQuery(query="BEGIN") FE=> SimpleQuery(query="BEGIN") FE=> SimpleQuery(query="BEGIN READ ONLY") FE=> SimpleQuery(query="BEGIN") ..... ``` Basically every `BEGIN` (and that's in the thousands) etc. ends up there now, which seems to regress performance. But maybe it's also a completely different place that is impacted by keeping the QUERY_EXECUTE_AS_SIMPLE flag and thus reducing performance. Unfortunately, I can't share the project at hand, but I hope you have enough information to investigate things. Let me know if I can help in any way. Cheers, Christoph