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 1ubgxD-0041gv-JZ for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Jul 2025 14:48:23 +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 1ubgxA-002ayg-SO for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Jul 2025 14:48:21 +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 1ubgxA-002ayY-HX for pgsql-hackers@lists.postgresql.org; Tue, 15 Jul 2025 14:48:21 +0000 Received: from mail-io1-xd29.google.com ([2607:f8b0:4864:20::d29]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ubgx8-007tKI-3A for pgsql-hackers@lists.postgresql.org; Tue, 15 Jul 2025 14:48:20 +0000 Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-8731c4ba046so454187839f.3 for ; Tue, 15 Jul 2025 07:48:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752590897; x=1753195697; 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=2gulXwtDfszcOMJ7l2N739Q4btMVHvL+1RrXCQPXsQc=; b=NTrq79aHVHhwZRUNAFnddbgn2XFrFlz74G/ad5hnNvZjUCF4y5FTBngaApDVeazXTI bq6kbVo7uyEmSgcVTt5NKn6/WUaav7H+sY2hAE0COPQQPTU8PXLpjMDK6JaAuPLrVfOB jjuuwCIHNmHnhW9X71t3EnkIOI0gM6Z0W8s5F1407IIP1nlvejv6O8JyT0uoik8RGLsV 9LBpCenolW7qt9EYpmDoUqCBGy3yv1FiMS3jP7s0Ohut4RahhphnF6PvqwudFGCeQI7R fIv3zQHmIf0BoxGUkNdatb0+V8wJmsls/PKJzxMWh3mnQBStxbbeSnxl5hCYR4uh9U5z 9GDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752590897; x=1753195697; 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=2gulXwtDfszcOMJ7l2N739Q4btMVHvL+1RrXCQPXsQc=; b=Z65wkEE21rU8rrMi7OShpk1R6gDrH5x50danOIJxYEWQzSyzb8xfC7EorrfKDd6f3E Wyc2xQqXKMTpZxeuXtSL9dJaV49L0GjofsB72hnBgFKWYEAkkn1VH9MwnoDDSq1UPzaD 2YVTRHERdf3rbIcsAzaNljKun2PBLo8n5cajqTcLTb3LKFa/dBo0qjN2/mefx380Xh31 N9d6K+PA1/2KPDG5rXvnZ5v12lI/PanbOiJ2jquvSq5oFT2iNTwlK8CYAkh+Mb+mo4Ar VZKOHKoIoQK6XwWO2B7/APWRm9xm4jWBCWnHqZ9P1qCc9sMwE5HbKghMl1tV63YvemdC 88QA== X-Forwarded-Encrypted: i=1; AJvYcCXqyar9nFmm1l0053gIkQdEfp2YnuMzc8ILxTI2x9jg2hDYz9feYu7zmbp2S2U0n1ADlYLVpZl8bCCMKNJO@lists.postgresql.org X-Gm-Message-State: AOJu0YwZNFmL2rM5xPGR9q6SW7Ha+ekMEPDxKsc0bdVrdAGEKgljGON0 HswwvoxjsL9w/SWCMs+Zyfp5kydS6pneQtIavm8YHA9PGGm6QWLN3NljPau7rSkRkccyIJ1ViDq vCaOKDDTiyv72NUcJAnWPq7lw6ljkMXg= X-Gm-Gg: ASbGncuSMRJcLlyTjdInrVeaIJUvJuLd3C+eO6Z/gyRqdwfNTWhQk9w/sZDCtScQGP+ OMVxQ1Y1uYk21mYsMZi++tS2odaIAN1JNRt+gaJSioUGtzlBmtdUMA8NDRNR7EIT/xlrmfqW068 4Uc7Od3UJdeYtH3FPkstbot6042npgZDF0vobagUp5xR54IuUZFRkbdpTJjADM/iBIIR+fNQtHg 2Fa3cD1wyDasp9dACKx3Y2OojnnNqbhC/39t+IRJg== X-Google-Smtp-Source: AGHT+IGtLScpu+hOvHHmDLmojteNX7N6p/OPgZRWY5zJnRDnvuPdVy3DK985pw9M6RqoCc7eKX9UUvf3SNEpovosvCI= X-Received: by 2002:a05:6602:6426:b0:876:b8a0:6a16 with SMTP id ca18e2360f4ac-8797886bf6cmr1930383039f.13.1752590896733; Tue, 15 Jul 2025 07:48:16 -0700 (PDT) MIME-Version: 1.0 References: <70BA294B-5A33-4F47-A637-8011C1F279CB@gmail.com> In-Reply-To: From: Alexander Kukushkin Date: Tue, 15 Jul 2025 16:48:05 +0200 X-Gm-Features: Ac12FXyK0PGiPFJJdwVBuToHQ2GNGQFroSLqZlbhajXK-m24AWV7Z8ibvZC6cjA 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="000000000000d621420639f8dd15" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000d621420639f8dd15 Content-Type: text/plain; charset="UTF-8" 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 --000000000000d621420639f8dd15 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

I total= ly understand the wish to make pg_stat_statements useful for workloads that= create/drop a ton of temporary tables.
However,=C2=A0when pursui= ng 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;

<= /div>
select * from pg_stat_statements;
userid =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 10
dbid =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 5
topl= evel =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | t
= queryid =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0| -8317141500049987426
query =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| select count(id) from s1.t
plans= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0| 0
total_plan_time =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| 0
m= in_plan_time =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| 0
max_pla= n_time =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| 0
mean_plan_tim= e =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 0
stddev_plan_time =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 0
calls =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| 2
total_exec_time =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| 22.577107
min_exec_time =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| 0.325021
max_exec_time =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| 22.252086000000002
mean_exec_time = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 11.2885535
stddev_exec_time = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 10.963532500000001
rows =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 2
s= hared_blks_hit =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| 4425

That is, two different queries, accessing two absolutely d= ifferent tables (one of them has 100000 times more rows!) were merged toget= her.
=C2=A0
Regard= s,
--
Alexander Kukushkin
--000000000000d621420639f8dd15--