Re: queryId constant squashing does not support prepared statements
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Sami Imseih <samimseih@gmail.com>
Cc: Dmitry Dolgov <9erthalion6@gmail.com>, Junwang Zhao <zhjwpku@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-05-08T23:47:58Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix typo in comment
- a3994ec6acb2 18.0 landed
-
Make query jumbling also squash PARAM_EXTERN params
- c2da1a5d6325 18.0 landed
-
Fix squashing algorithm for query texts
- 0f65f3eec478 18.0 landed
-
pg_stat_statements: Fix parameter number gaps in normalized queries
- 3c03b8cd7979 13.22 landed
- 8a1459f62ad1 14.19 landed
- 130300a15407 15.14 landed
- 7e8b44f4e0e6 16.10 landed
- 290e8ab32ac5 17.6 landed
- 35a428f30b15 18.0 landed
On Thu, May 08, 2025 at 03:50:32PM -0500, Sami Imseih wrote: > On Thu, May 8, 2025 at 2:36 PM Dmitry Dolgov <9erthalion6@gmail.com> wrote: >> To clarify, I had in mind something like in the attached patch. The >> idea is to make start/end location capturing relatively independent from >> the constants squashing. The new parsing node conveys the location >> information, which is then getting transformed to be a part of an >> ArrayExpr. It's done for in_expr only here, something similar would be >> needed for array_expr as well. Feedback is appreciated. > > Thanks! I took a quick look at v1-0001 and it feels like a much better approach > than the quick hack I put together earlier. I will look thoroughly. SELECT query, calls FROM pg_stat_statements ORDER BY query COLLATE "C"; - query | calls -----------------------------------------------------+------- - SELECT ARRAY[$1 /*, ... */] | 1 - SELECT pg_stat_statements_reset() IS NOT NULL AS t | 1 + query | calls +-------------------------------------------------------+------- + SELECT ARRAY[$1, $2, $3, $4, $5, $6, $7, $8, $9, $10] | 1 + SELECT pg_stat_statements_reset() IS NOT NULL AS t | 1 (2 rows) Yes, we are going to need more than that for such cases if we want to cover all the ground we're aiming for. Putting that aside, the test coverage for ARRAY[] elements is also very limited on HEAD with one single test only with a set of constants. We really should improve that, tracking more patterns and more mixed combinations to see what gets squashed and what is not. So this should be extended with more cases, including expressions, parameters and sublinks, with checks on pg_stat_statements.calls to see how the counters are aggregated. That's going to be important when people play with this code to track how things change when manipulating the element jumbling. I'd suggest to do that separately of the rest. -- Michael