Re: query_id: jumble names of temp tables for better pg_stat_statement UX
Alexander Kukushkin <cyberdemn@gmail.com>
From: Alexander Kukushkin <cyberdemn@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Sami Imseih <samimseih@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, Christoph Berg <myon@debian.org>, Lukas Fittl <lukas@fittl.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
ma lz <ma100@hotmail.com>
Date: 2025-07-15T14:48:05Z
Lists: pgsql-hackers, pgsql-general
Hi, I totally understand the wish to make pg_stat_statements useful for workloads that create/drop a ton of temporary tables. However, when pursuing this goal we impacted other types of totally valid workloads when tables with the same name exist in different schemas. Example: create schema s1; create table s1.t as select id from generate_series(1, 10) as id; create schema s2; create table s1.t as select id from generate_series(1, 1000000) as id; select count(id) from s1.t; select count(id) from s2.t; select * from pg_stat_statements; userid | 10 dbid | 5 toplevel | t queryid | -8317141500049987426 query | select count(id) from s1.t plans | 0 total_plan_time | 0 min_plan_time | 0 max_plan_time | 0 mean_plan_time | 0 stddev_plan_time | 0 calls | 2 total_exec_time | 22.577107 min_exec_time | 0.325021 max_exec_time | 22.252086000000002 mean_exec_time | 11.2885535 stddev_exec_time | 10.963532500000001 rows | 2 shared_blks_hit | 4425 That is, two different queries, accessing two absolutely different tables (one of them has 100000 times more rows!) were merged together. Regards, -- Alexander Kukushkin
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