Repository navigation
perf: skip session control regex for queries starting with SELECT, INSERT, etc - #2036
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
levkk
approved these changes
Nov 13, 2026
Contributor
|
Metal bench (arm64) passed. All 520 measures within bounds.
Counters per txn
Microbench: all 507 measures within bounds. Hot code per txn
pooler:
sharding-w2:
Logslb, microbench, pooler, sharding-w2, sharding-w8, verdict.json Compared 75bc8ac with 5bb8ba3 on c8g.metal-24xl (on-demand). |
Contributor
|
Metal bench (x86) passed. All 520 measures within bounds.
Counters per txn
Microbench: all 507 measures within bounds. Hot code per txn
pooler:
sharding-w2:
Logslb, microbench, pooler, sharding-w2, sharding-w8, verdict.json Compared 75bc8ac with 5bb8ba3 on c7i.metal-48xl (on-demand). |
jkaczman
force-pushed
the
jk-regex-skip-common-queries
branch
from
November 14, 2026 03:50
75bc8ac to
705da07
Compare
jkaczman
force-pushed
the
jk-regex-skip-common-queries
branch
from
November 14, 2026 03:51
705da07 to
bb31092
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, with
query_parserset to auto or session_control, we were running the session control regex on all queries to look for SET, BEGIN, COMMIT, etc. This includes queries such as SELECT 1. In the pooler microbench flamegraph (#2035), the check was a pretty substantial amount (see below):Now, if the query starts with SELECT, INSERT, UPDATE, DELETE or WITH, we return early and skip the expensive regex call.
How can we do this? All of the session control patterns occur at the very start of the query text (when there's no whitespace / comment present); i.e., if we have a query that starts with a keyword like
SELECT, which isn't in theCMD_BASEkeywords, there's no point in trying to match withCMD_RE.session_control_and_locksbehavior not changed