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 1ubvVg-006yWz-RZ for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Jul 2025 06:20:56 +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 1ubvVe-007rnr-Tv for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Jul 2025 06:20:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ubvVe-007rnj-JM for pgsql-hackers@lists.postgresql.org; Wed, 16 Jul 2025 06:20:55 +0000 Received: from mail-io1-xd2c.google.com ([2607:f8b0:4864:20::d2c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ubvVd-0080hV-03 for pgsql-hackers@lists.postgresql.org; Wed, 16 Jul 2025 06:20:54 +0000 Received: by mail-io1-xd2c.google.com with SMTP id ca18e2360f4ac-86d013c5e79so509361739f.0 for ; Tue, 15 Jul 2025 23:20:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752646851; x=1753251651; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=zI/88Yi+9FvQ1AzTs/dnE1Vb036K6Ecmc3gDHHKPpb8=; b=KU1eairR8xvcr0ovJOoqniOx1kb8bT2jRAJ4vUdRT61b/c7I9HylynYUha48YhdmO/ kGGkcLznSCUAT4uPopK9eYIVbfH7LoGM7ZPpTJi3lCfSHzx1Kyi2OUa/Vtmez8f7UqQi 7VcH9CCdiO1Dmrhd4iCDc3cmX187OiiIQE9Oslh14fV9V41uE+WDFEEQEm/M7eAPpyKh Q2fwFjqTNza4X4r7WmiL4Zf9QsMh1BY0o8qbjAYsAeUjKMrMe041LFtIK7hrjCPsqPyw SG4CPlqwY8n7Epmf+qxx8p4Dww59Yt+Qb7IdNSjtrLP2rjTdQyKWYc9Lo4bJDdhFZSxz qVhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752646851; x=1753251651; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zI/88Yi+9FvQ1AzTs/dnE1Vb036K6Ecmc3gDHHKPpb8=; b=WC/6f3eDesfRdbPSh75eUIblKpIxQf8PpuQZ3luIlD9CF01DwnuxDZTHN/pUR67+IL usPJZv62tezbz4JQaNygVeIUjdsOzBD3kPKYLIa7K+lPqF/2o0Pb1HZCKbkY/2jERNFs pqq6p/NVoxgzq13emzZte9eyfeyi4kr8GoOY8FRJ8MIAZpCgXK0YNikaHCN9IGdNNB7k 0yH59+5WJRrkNTBDNAiSEDcAarZ9/C824ahLRUP9jMMjHd9QNBHVFYTVPp13Si5Rf+Rp 5zmLDEY7XhYcicjegZGd8eoomjgdE4UnW1N1+Q9GA+8V1RgknajLyr0dE1MICi5VsbAr GyvQ== X-Forwarded-Encrypted: i=1; AJvYcCUNya8S2ASijxow1s3kJ+dPEKgG/gibY/zWGDylJj9kCJVVoscBQMn8DOvfNH5poS1r4hAFby80xihRYhOf@lists.postgresql.org X-Gm-Message-State: AOJu0Yz54QYcq94le25yGTVkjro+eT5HVTaEYaCcvGJ4iFUi9nCIIsxX IOfRRBT1Hx5GE8Q558a317TUBOS3QA/bMVxzXfVdYNHvg4ibeMHzfTfkAMVffFkZr35wfn1YaBG w3yL+t9q1ESpcOKL87/JUi9XHXTNlqJ8= X-Gm-Gg: ASbGncuQVFAZdWcwVRUThhzO8+HGe2jg2r8wtsC0wu9cN+J/G0NNx58JwGXy4srlkjW ss19VuxF4pZHjOAI9Fpz3AXGjRvqFu67G5mZzfxUGMXx8GNLmO8xKRQyW10+lf7VmkrnQc8LBQM nPgdzprknw6EB3YLpXyAZWIPZZMUe6LdN8JLeZEywtlI/lIUMBMA6hHIRVKC4/ZYAr/7PsdlwzS 0+1jZzRNlmrKgE707v5D9s4lkMVQxRvWGbKf4msEw== X-Google-Smtp-Source: AGHT+IHuxWTYYiFLrN0oL/i3gke9XV8NQbfkicSznfWD2+uLlOFb8WY7AZABKGMDhJWWwrk9F8Sa9M1z391yrfDQZa0= X-Received: by 2002:a05:6602:6b07:b0:861:d8ca:3587 with SMTP id ca18e2360f4ac-879c29170cdmr140246139f.4.1752646850716; Tue, 15 Jul 2025 23:20:50 -0700 (PDT) MIME-Version: 1.0 References: <70BA294B-5A33-4F47-A637-8011C1F279CB@gmail.com> In-Reply-To: From: Alexander Kukushkin Date: Wed, 16 Jul 2025 08:20:39 +0200 X-Gm-Features: Ac12FXxKUvcu__UnKye74iEhH_QBMHDseO_7eOau_lf4eYDK7__Yu_K6zIyGC78 Message-ID: Subject: Re: query_id: jumble names of temp tables for better pg_stat_statement UX To: Michael Paquier Cc: Sami Imseih , Tom Lane , Christoph Berg , Lukas Fittl , PostgreSQL Hackers , ma lz Content-Type: multipart/alternative; boundary="000000000000f429dc063a05e45b" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000f429dc063a05e45b Content-Type: text/plain; charset="UTF-8" On Wed, 16 Jul 2025 at 01:39, Michael Paquier wrote: > > > 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; > > I suspect that you mean s2.t and not s1.t here. > Yes. > Yes, we had this argument upthread, and it is still possible to > differentiate both cases by using a different alias in the FROM > clause, as of: > select count(id) from s1.t as t1; > select count(id) from s2.t as t2; > > The new behavior where we do not need to worry about temporary tables, > which is not that uncommon because some workloads like using these for > JOIN patterns as a "temporary" anchor in a session, has more benefits > IMO, particularly more if the connections have a rather higher > turnover. Yes, I've seen this argument and know that aliases will make these queries look different. However, we regularly hear from many different customers that they *don't control queries* sent by application or *can't modify these queries*. Such kinds of workloads are also not that uncommon and this change makes it impossible to monitor them. I would somewhat understand when a table in the query is used without specifying schema and such queries are merged together: s1: SET search_path s1; select count(*) from t; s2: SET search_path s2; select count(*) from t; But, even this case doesn't feel right, because these tables are still different and therefore queries. Regards, -- Alexander Kukushkin --000000000000f429dc063a05e45b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Wed, 16 Jul = 2025 at 01:39, Michael Paquier <m= ichael@paquier.xyz> wrote:

> 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;=

I suspect that you mean s2.t and not s1.t here.

Yes.=C2=A0
=C2=A0
Yes, we had this argument upthread, and it is still possible to
differentiate both cases by using a different alias in the FROM
clause, as of:
select count(id) from s1.t as t1;
select count(id) from s2.t as t2;

The new behavior where we do not need to worry about temporary tables,
which is not that uncommon because some workloads like using these for
JOIN patterns as a "temporary" anchor in a session, has more bene= fits
IMO, particularly more if the connections have a rather higher
turnover.

Yes, I've seen this argument = and know that aliases will make these queries look different.
How= ever, we regularly hear from many different=C2=A0customers that they *don&#= 39;t control queries* sent by application or *can't modify these querie= s*.
Such kinds of wo= rkloads are also not that uncommon and this change makes it impossible to m= onitor them.

I would somewhat und= erstand when a table in the query is used without specifying schema and suc= h queries are merged together:
s1: SET search_path s1; select count(*) from t;
s2: SET search_path s2; select cou= nt(*) from t;

<= /span>
But, even this case= doesn't feel right, because these tables are still different and there= fore queries.

<= /span>
Regards,
--
Alexander Kukushkin
= --000000000000f429dc063a05e45b--