Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tw1ee-00A200-CL for pgsql-hackers@arkaria.postgresql.org; Sat, 22 Mar 2025 16:25:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tw1ec-00G2xO-VA for pgsql-hackers@arkaria.postgresql.org; Sat, 22 Mar 2025 16:24:58 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tw1ec-00G2xG-LY for pgsql-hackers@lists.postgresql.org; Sat, 22 Mar 2025 16:24:58 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tw1eb-000X6k-09 for pgsql-hackers@lists.postgresql.org; Sat, 22 Mar 2025 16:24:57 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 52MGOhku080507; Sat, 22 Mar 2025 12:24:43 -0400 From: Tom Lane To: Michael Paquier cc: Christoph Berg , PostgreSQL Hackers , ma lz Subject: Re: query_id: jumble names of temp tables for better pg_stat_statement UX In-reply-to: <1831838.1742656359@sss.pgh.pa.us> References: <1831838.1742656359@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Sat, 22 Mar 2025 11:12:39 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <80505.1742660683.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 22 Mar 2025 12:24:43 -0400 Message-ID: <80506.1742660683@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I wrote: > So my feeling is: if we think this is the behavior we want, let's do > it across the board. I suggest that we simply drop the relid from the > jumble and use the table alias (that is, eref->aliasname) instead. I experimented with this trivial fix (shown in-line to keep the cfbot from thinking this is the patch-of-record): diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes= .h index 23c9e3c5abf..a54bbdc18b7 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -1051,7 +1051,7 @@ typedef struct RangeTblEntry /* user-written alias clause, if any */ Alias *alias pg_node_attr(query_jumble_ignore); /* expanded reference names */ - Alias *eref pg_node_attr(query_jumble_ignore); + Alias *eref; = RTEKind rtekind; /* see above */ = @@ -1094,7 +1094,7 @@ typedef struct RangeTblEntry * tables to be invalidated if the underlying table is altered. */ /* OID of the relation */ - Oid relid; + Oid relid pg_node_attr(query_jumble_ignore); /* inheritance requested? */ bool inh; /* relation kind (see pg_class.relkind) */ This caused just one diff in existing regression test cases: diff --git a/contrib/pg_stat_statements/expected/planning.out b/contrib/pg= _stat_statements/expected/planning.out index 3ee1928cbe9..c25b8b946fd 100644 --- a/contrib/pg_stat_statements/expected/planning.out +++ b/contrib/pg_stat_statements/expected/planning.out @@ -75,8 +75,9 @@ SELECT plans >=3D 2 AND plans <=3D calls AS plans_ok, ca= lls, rows, query FROM pg_sta WHERE query LIKE 'SELECT COUNT%' ORDER BY query COLLATE "C"; plans_ok | calls | rows | query = ----------+-------+------+-------------------------------------- - t | 4 | 4 | SELECT COUNT(*) FROM stats_plan_test -(1 row) + f | 1 | 1 | SELECT COUNT(*) FROM stats_plan_test + f | 3 | 3 | SELECT COUNT(*) FROM stats_plan_test +(2 rows) = -- Cleanup DROP TABLE stats_plan_test; 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. regards, tom lane