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: Álvaro Herrera <alvherre@kurilemu.de>, Dmitry Dolgov <9erthalion6@gmail.com>, Junwang Zhao <zhjwpku@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-05-30T05:03:19Z
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
Attachments
- regression.diffs (text/plain)
On Thu, May 29, 2025 at 11:30:12AM +0900, Michael Paquier wrote:
> I still need to review the rest of the patch series..
The test additions done in v7-0002 look sensible here.
--- In the following two queries the operator expressions (+) and (@) have
--- different oppno, and will be given different query_id if squashed, even though
--- the normalized query will be the same
In v7-0002, this comment is removed, but it still applies, isn't it?
+-- The casted ARRAY expressions will have the same queryId as the IN clause
+-- form of the query
Interesting distinction that explains the differences in counts. Yes
it's a good idea to track this kind of behavior in the tests.
--- Bigint, explicit cast is not squashed
+-- Bigint, explicit cast is squashed
Seems incorrect with 0002 taken in isolation. The last cast is still
present in the normalization. It's not after v7-0003.
Already mentioned upthread, but applying only v7-0003 on top of
v7-0002 (not v7-0004) leads to various regression failures in dml.sql
and squashing.sql. The failures persist with v7-0004 applied. Please
see these as per the attached, the IN lists do not get squashed, the
array elements are. Just to make sure that I am not missing
something, I've rebuilt from scratch with no success.
IsSquashableExpressionList() includes this comment, which is outdated,
probably because squashing was originally optional behind a GUC and
the parameter has been removed while the comment has not been
refreshed:
/*
* If squashing is disabled, or the list is too short, we don't try to
* squash it.
*/
RecordExpressionLocation()'s top comment needs a refresh, talking
about constants. The simplifications gained in pgss.c's normalization
are pretty cool.
+ bool has_squashed_lists;
[...]
+ if (jstate->has_squashed_lists)
+ jstate->highest_extern_param_id = 0;
This new flag in JumbleState needs to be documented, explaining why
it needs to be here. I have to admit that it is strange to see
highest_extern_param_id, one value in JumbleState be forced to zero in
the PGSS normalization code if has_squashed_lists is set to true.
This seems like a layer violation to me: JumbleState should only be
set while in the jumbling code, not forced to something else
afterwards while in the extension.
--
Michael