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 1uf700-002Ggj-7h for pgsql-hackers@arkaria.postgresql.org; Fri, 25 Jul 2025 01:13:25 +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 1uf6zy-00DDDN-8F for pgsql-hackers@arkaria.postgresql.org; Fri, 25 Jul 2025 01:13:22 +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 1uf6zx-00DDDF-ER for pgsql-hackers@lists.postgresql.org; Fri, 25 Jul 2025 01:13:22 +0000 Received: from fhigh-a1-smtp.messagingengine.com ([103.168.172.152]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uf6zt-000hF6-2o for pgsql-hackers@postgresql.org; Fri, 25 Jul 2025 01:13:21 +0000 Received: from phl-compute-07.internal (phl-compute-07.phl.internal [10.202.2.47]) by mailfhigh.phl.internal (Postfix) with ESMTP id ADAE014000B9; Thu, 24 Jul 2025 21:13:17 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-07.internal (MEProxy); Thu, 24 Jul 2025 21:13:17 -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=1753405997; x=1753492397; bh=QjZxyj1CMs rVislkdKkjAC3uUt5n43j7RaAZinm4wUc=; b=LYEV/yuocRd6RI8VAYcLRC1yUa rGsH59SeY9+4nz3YV2Ysb90Z+K97z9o2eiwVD30HE0KYimsttRDpEpgg/6ItkiVj 8g5bRTie8P9j5aHS+nKWDh3aZ9Vivm9jD7o6wqBcAKFCcFosCrOcCQgxsESy0+K1 1Bwg/+M3sZ7lQK6TVLq0jYx9a7/jO+727BhZTKKUq5sGamR4lie707MRgrpTH0oB Ov57eXlRGJvsx4r7pcNwQ4Yrq30OKZBIgeDKTy9R11W0UQKQH8EbbsSECWH+AbTw Kj5UFfEI6y5kz+UaNPpJI2IHF512GJOpfxlsDUB9ONUBGi+4ShunBXUlH9GQ== 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= 1753405997; x=1753492397; bh=QjZxyj1CMsrVislkdKkjAC3uUt5n43j7RaA Zinm4wUc=; b=cIOcDeONj08NDnvgXSUHl2mXwkHj3LP3f3mLt8ikcv10+qpnUOG ygp1DCvVYWQFyExCvf85KxxIzN+fK/FeAy98UTyg7xeF0lue40mX8gV44bWXguDw EQrttqtNyLUpNjmv8JpZsW4TCvuLOyFjGW5IuWGjqM+6in50vaEjC3E5+Z4VywvS SUx0my9k0HL48jPdTN0jTZpShL1ofKss7shy8GTFV/RshN2Zouzj3xDO668lYz6k lMWqVNY+Of75Y607YL+t/mYzZ3Sa65Cj4LIsWGHYconJTwQTmNfSLtxo9SYrtPYc jZKuTVoAXSTxGtK0eYYOkBZN6UNw42Ez7XQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdekvddukecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlh cuvffnffculdejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvden ucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprghquh hivghrrdighiiiqeenucggtffrrghtthgvrhhnpeetleeifedufffhhfdtteelgeeggeff hfekueevteeigfduudevudetgfegiedvjeenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiipdhn sggprhgtphhtthhopeejpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehsrghmih hmshgvihhhsehgmhgrihhlrdgtohhmpdhrtghpthhtohepthhglhesshhsshdrphhghhdr phgrrdhushdprhgtphhtthhopehlvghpihhhohhvsehgmhgrihhlrdgtohhmpdhrtghpth htohephhhtrghmfhhiughssehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdq hhgrtghkvghrshesphhoshhtghhrvghsqhhlrdhorhhgpdhrtghpthhtohepnhhikhesph hoshhtghhrvghsrdgrihdprhgtphhtthhopehilhihrgdrvghvughokhhimhhovhesthgr nhhtohhrlhgrsghsrdgtohhm X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 24 Jul 2025 21:13:14 -0400 (EDT) Date: Fri, 25 Jul 2025 10:13:02 +0900 From: Michael Paquier To: Sami Imseih Cc: Tom Lane , Andrei Lepikhov , Greg Sabino Mullane , pgsql-hackers , Nikolay Samokhvalov , Ilia Evdokimov Subject: Re: track generic and custom plans in pg_stat_statements Message-ID: References: <1647760.1753369510@sss.pgh.pa.us> <1673684.1753379027@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="IwB45JZ+LRckAgQf" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --IwB45JZ+LRckAgQf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Jul 24, 2025 at 01:14:47PM -0500, Sami Imseih wrote: >> Sami Imseih writes: >>>> That is not to say that I think 719dcf3c4 was a good idea: it looks >>>> rather useless from here. It seems to me that the right place to >>>> accumulate these sorts of stats is in CachedPlanSources, and I don't >>>> see how this helps. What likely *would* help is some hooks in >>>> plancache.c for pg_stat_statements to connect into so it can count >> >>> One possible hook for accumulating custom and generic plans per >>> queryId would be inside GetCachedPlan. However, this would require >>> calling pgss_store an extra time, in addition to ExecutorEnd, every time >>> GetCachedPlan is executed, which could introduce non-negligible >>> overhead. I would suspect more contention on the PGSS locks in the prepared statement and/or extended query protocol case if we were to do that. With the amount of information we want to track in PGSS, which is that we want to know from where a plan is coming from (generic cache, custom cache or something else), FWIW I'm still OK with this information added in PlannedStmt itself to be able to link back to the state retrieved at the end of the executor because it's also cost-free. I'm also OK to be proved wrong based on arguments that could justify the addition of an extra hook, but I don't really see the use-cases that could justify such additions yet. Perhaps CachedPlanType is misnamed, though, would it be more suited to name that as a sort of "origin" or "source" field concept? We want to know which which source we have retrieved a plan that a PlannedStmt refers to. -- Michael --IwB45JZ+LRckAgQf Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmiC2h4ACgkQnvQgOdby QH2BUg//U1N07SEj4r4MPCzzDrzYE+xG5Ybi/QepledS51/BKqd67fRMFgcQ8UqA XmaKS9BJQBIZbk9mMZErnCyZFKmKkw3TslKnGBH2riC4l1gKzNZDUoeKRsNKfcnH 6Ev7GXX9Hemwc34LrXcgXti0t6S3AypqoOvKCG1oVQT0Loq8o70rtq5cZgjdClUP Ohg+bU4BtbicX79h8jWdyEMQUc4idmc10z+/+vCtx6Xhw6BGAuw3IbRqc28Bv80s ybxiYeWJSM7mvgfsgumLRsEY5X4SEcsdEguJIyEmF706Z3pB9ukrJdYvL9dS0clN KhD6OPLAhS/YRBJkAqVDWwGKWFNm7TJeaZ+ItTjOMtGDQZfCd9ojtXfHTsluKrH9 MtC01NgEUfn7I+jd8qddIXB7ENoIx1PaNmBwUef2GMD9uyksn8bZ23OB4vqfZKXm SJaL5mjFJQBSpD3righ1M+gyeHDUwq8SLQozvt3MtvLzjlmPt1vND7DopeswX+YV f5PxwUeyNV9lF2iD5NZACAFUlqVdGQewxkqfsZBnYfxxgM7Yf2348xIDEk4CixSV 45QGxQQjiJAU3OOvRtSKkTZWvcckyFjXYlnHlT39GvM2xJr5sgz/OC+PgJUERKov xv1u28U+vhdRivFBM9eMUOGJLGkSP9EmVKSaQlMG3p9W07eO9s4= =A/oB -----END PGP SIGNATURE----- --IwB45JZ+LRckAgQf--