On Mon, Sep 30, 2024 at 5:14 PM jian he <jian.universal...@gmail.com> wrote: > Is it possible to normalize top level utilities explain query, make > these two have the same queryid? > explain(verbose) EXECUTE test_prepare_pgss1(1, 2); > explain(verbose) EXECUTE test_prepare_pgss1(1, 3); > > I guess this is a corner case.
This seems to be a known issue. The test_prepare_pgss1's parameters are A_Const nodes. Those nodes have a custom query jumble which doesn't record location[1] and thus can't be normalised by pgss. That could be fixed by replacing the switch on nodeTag by JUMBLE_LOCATION(location) but this will impact a lot of DDL queries and the result doesn't look great (for example, "BEGIN TRANSACTION NOT DEFERRABLE, READ ONLY, READ WRITE, DEFERRABLE" would be normalised as "BEGIN TRANSACTION $1 DEFERRABLE, $2 ONLY, $3 WRITE, $4") Looking at the commit for the A_Const's jumble, this is mentioned by Michael[2]: > (FWIW, I'd like to think that there is an argument to normalize the > A_Const nodes for a portion of the DDL queries, by ignoring their > values in the query jumbling and mark a location, which would be > really useful for some workloads, but that's a separate discussion I > am keeping for later.) I haven't found any recent discussion but this should live in a different thread as this is a separate issue. [1]: https://github.com/postgres/postgres/blob/cf4401fe6cf56811343edcad29c96086c2c66481/src/backend/nodes/queryjumblefuncs.c#L323-L355 [2]: https://www.postgresql.org/message-id/y9+huyslmap6y...@paquier.xyz