Re: query_id: jumble names of temp tables for better pg_stat_statement UX
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Christoph Berg <myon@debian.org>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, ma lz <ma100@hotmail.com>
Date: 2025-03-23T00:47:31Z
Lists: pgsql-hackers, pgsql-general
On Sat, Mar 22, 2025 at 12:24:43PM -0400, Tom Lane wrote:
> I experimented with this trivial fix (shown in-line to keep the cfbot
> from thinking this is the patch-of-record):
>
> What's happening there is that there's an ALTER TABLE ADD COLUMN in
> the test, so the executions after the first one see more entries
> in eref->colnames and come up with a different jumble. I think
> we probably don't want that behavior; we only want to jumble the
> table name. So we'd still need the v3-0001 patch in some form to
> allow annotating RangeTblEntry.eref with a custom jumble method
> that'd only jumble the aliasname.
Alias.aliasname is not qualified, so it means that we'd begin to
assign the same query ID even if using two relations from two schemas
depending on what search_path assigns, no? Say:
create schema popo1;
create schema popo2;
create table popo1.aa (a int, b int);
create table popo2.aa (a int, b int);
set search_path = 'popo1';
select count(*) from aa;
set search_path = 'popo2';
select count(*) from aa;
=# select query, calls from pg_stat_statements where
query ~ 'select count';
query | calls
-------------------------+-------
select count(*) from aa | 2
(1 row)
Perhaps that's OK because such queries use the same query string, but
just silencing the relid means that we'd lose the namespace reference
entirely, making the stats potentially fuzzier depending on the
workload. On HEAD, one can guess the query ID with an EXPLAIN and a
search_path, as well, so currently it's possible to cross-check the
contents of pgss. But we'd lose this possibility here..
--
Michael
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Use relation name instead of OID in query jumbling for RangeTblEntry
- 787514b30bb7 18.0 landed
-
Fix two issues with custom_query_jumble in gen_node_support.pl
- 27ee6ede6bc9 18.0 landed
-
pg_stat_statements: Add more tests with temp tables and namespaces
- 3430215fe35f 18.0 landed
-
Add support for custom_query_jumble as a node field attribute
- 5ac462e2b7ac 18.0 landed