Re: Refactor query normalization into core query jumbling
Lukas Fittl <lukas@fittl.com>
From: Lukas Fittl <lukas@fittl.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Sami Imseih <samimseih@gmail.com>, zengman <zengman@halodbtech.com>, pgsql-hackers <pgsql-hackers@postgresql.org>,
Julien Rouhaud <rjuju123@gmail.com>
Date: 2026-03-27T07:19:01Z
Lists: pgsql-hackers
On Thu, Mar 26, 2026 at 10:18 PM Michael Paquier <michael@paquier.xyz> wrote: > This line of arguments is stronger for the normalization of the query > string. Why should the core code decide what a normalized string > should look like when it comes to the detection of the constants, if > any? Instead of a dollar-quoted number, we could enforce a bunch of > things, like a '?' or a '$woozah$' at these locations. Fair enough, though I haven't seen any extensions that do that in practice - its reasonable to have normalization result in a query string that's parsable again and can be passed to EXPLAIN (GENERIC_PLAN). > Saying that, the key point of the patch is to take a copy of the > JumbleState locations, and recompute it for the needs of PGSS for the > sake of the normalized query representation. Hence, why don't we just > do that at the end? That should be enough to enforce the const marker > for the JumbleState across all the loaded extensions that want to look > at it. This leads me to the simpler patch attached. > > Comments or tomatoes? That's simpler, and I'd be OK with just that > for v19. That would be much better than the current state of affairs, > where PGSS decides to enforce its own ideas in the JumbleState, ideas > fed to anything looping into the post-parse-analyze hook after PGSS. I'm not convinced that making the const change alone is a good idea, without also providing some helpers to reduce the repeated code in extensions. What if we only put the ComputeConstantLengths (as Sami had it in v7) in core, together with making JumbleState const? Thanks, Lukas -- Lukas Fittl
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Mark JumbleState as a const in the post_parse_analyze hook
- 49cc0d41488b 19 (unreleased) landed
-
Force standard_conforming_strings to always be ON.
- 45762084545e 19 (unreleased) cited
-
Move pg_stat_statements query jumbling to core.
- 5fd9dfa5f50e 14.0 cited