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 1ubpFb-005koE-9t for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Jul 2025 23:39:55 +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 1ubpFZ-006MJH-95 for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Jul 2025 23:39:53 +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 1ubpFY-006MJ9-Va for pgsql-hackers@lists.postgresql.org; Tue, 15 Jul 2025 23:39:53 +0000 Received: from fout-b3-smtp.messagingengine.com ([202.12.124.146]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ubpFX-007xbZ-1j for pgsql-hackers@lists.postgresql.org; Tue, 15 Jul 2025 23:39:53 +0000 Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfout.stl.internal (Postfix) with ESMTP id B91D91D000DD; Tue, 15 Jul 2025 19:39:49 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Tue, 15 Jul 2025 19:39:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1752622789; x=1752709189; bh=liHROGQL0q WIsuBlTe61Qp8bZHUcOkbi88Txjffygjg=; b=cl+Zav5f6F7a8oWdHyOLXV3J83 XHpBluiatkXddE1hm5Michw93e5KwewQF2x1qsq1LWPnns/07LzNC9kdJIqx6UKN X5gysofvdyLKpDIiNplew5m0r5pJHrnpX0XTxz5OiChKmceDOUmRBkDKTvjBOHX0 XoSW1q4xTE7T4iFwW1hQj59hMxFJWOfz6V/+IeaxweVAM7auR6xAtXg1sf4G9TPw AR8wM3O3vjXr0PhyXOE+2WGw30Z5aWat2u7L2akiYlf9v0HT+IMvrZLw0uCFg2Ah W19dCKjtO5DHidYRSClyFpucyJzcEQnStQhHPDo+/Dw0GV9cXt3hzfse8CIg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1752622789; x=1752709189; bh=liHROGQL0qWIsuBlTe61Qp8bZHUcOkbi88T xjffygjg=; b=esxXjbcqOxxJp/CV3ghmYLMtP1kkNzdgaICwH7qTYV2+My11h5u Jl5LAp/p4/lqbeCNrZH6Zvj5dmcz7gaN1LDXBCf5HCwIpWZI8nXqJz0NAWm4eAQy rMw6cQIgTaXujpmy56zCq+Yfi6asmjKQHTQIfLiHJhvK/JMgIfXi7xsYpnXwWfVN Fk5ica5MIUZpTGuwOFVnnJ0hwJy3IXUFumg71k2v6Xu7pXm1CAPrW4YOeG0HNasY 8FmlMPyN8x5rTTJ6kFSj2BkncpfNfFUawjeyjhD5eft3nX5zGwBpb/49PXXMMenZ vHOU7Hz9BbsgcsWg/UiwzVNDOiFpLjGTPUA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdehiedujecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlh cuvffnffculdejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvden ucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprghquh hivghrrdighiiiqeenucggtffrrghtthgvrhhnpeetleeifedufffhhfdtteelgeeggeff hfekueevteeigfduudevudetgfegiedvjeenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiipdhn sggprhgtphhtthhopeejpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegthigsvg hruggvmhhnsehgmhgrihhlrdgtohhmpdhrtghpthhtohepshgrmhhimhhsvghihhesghhm rghilhdrtghomhdprhgtphhtthhopehtghhlsehsshhsrdhpghhhrdhprgdruhhspdhrtg hpthhtohepmhihohhnseguvggsihgrnhdrohhrghdprhgtphhtthhopehluhhkrghssehf ihhtthhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsheslhhishhtsh drphhoshhtghhrvghsqhhlrdhorhhgpdhrtghpthhtohepmhgruddttdeshhhothhmrghi lhdrtghomh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 15 Jul 2025 19:39:47 -0400 (EDT) Date: Wed, 16 Jul 2025 08:39:29 +0900 From: Michael Paquier To: Alexander Kukushkin Cc: Sami Imseih , Tom Lane , Christoph Berg , Lukas Fittl , PostgreSQL Hackers , ma lz Subject: Re: query_id: jumble names of temp tables for better pg_stat_statement UX Message-ID: References: <70BA294B-5A33-4F47-A637-8011C1F279CB@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="PIInvNc1NnQ68D8z" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --PIInvNc1NnQ68D8z Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Jul 15, 2025 at 04:48:05PM +0200, Alexander Kukushkin wrote: > 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; I suspect that you mean s2.t and not s1.t here. > select count(id) from s1.t; > select count(id) from s2.t; > > That is, two different queries, accessing two absolutely different tables > (one of them has 100000 times more rows!) were merged together. 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. -- Michael --PIInvNc1NnQ68D8z Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmh25rEACgkQnvQgOdby QH3QSRAApASrwWRMLNoEDD/z8hLe3PCb0PBOsGQE09zzcGz9mbRIz985u7iUPfwV ElqjbU3jQrLCfN8zd7y1xu1kzgdD65TkdJCJ/Kb8d68lfPAi3KXIiAmKPF0yq8Sa nzL6EeWCULWHzG3OwBD27ifF4nzyzTnDQIbTMurwG5ODeVaJIIjPzoBy2Wx1jkoh CDmGHXhlEcZGbVMp+FhpBquGzJReVE+1HDpcnM2O72jRrC+k11gqMsMERFr2MQD6 3TuBp3jCnktD2gBQHK1V7evHfnsE/xs5MrHHwiCvMUyFIkPAFUluUcUyYRFycXTn uhJzM5rMbWjDMjACymRm1mkFuAoKfNvFW3NSvgw45Tw+DvkOFphdaqlMjwJxcNma 3Jq74ZBWNMS7M+PqsRTkZUvakHu0ftITzfV9+Mt6GUSFuPgNTgBXXtfCkZ+1rpum 5O4mHjojYDvDS5m9oT4PNCWaEYRQCZarjtq6a1j3JeW1QYrtRt/ZAvwRN6n6oM5b NHwy2mAvxR7WVa+dZZTmI2HDjBDgZxsHL5+GW1QKCeYY5FoTZrffv1YsyM3WJah9 xpHGzaSFRwa1ObE0YB7jLXptycJwkaLkquhXOBGTe/UEzz6XeIYmsuttHbRWcYMI MiYd73QNHKp5WhW9cRGarvnBvEeAt7cPssml+0Y9KiItklc4T2g= =A/vg -----END PGP SIGNATURE----- --PIInvNc1NnQ68D8z--