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 1uexVX-00H8vn-JD for pgsql-hackers@arkaria.postgresql.org; Thu, 24 Jul 2025 15:05:20 +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 1uexVW-008gQY-GV for pgsql-hackers@arkaria.postgresql.org; Thu, 24 Jul 2025 15:05:18 +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 1uexVW-008gQQ-6t for pgsql-hackers@lists.postgresql.org; Thu, 24 Jul 2025 15:05:18 +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 1uexVU-000ZRH-2Q for pgsql-hackers@postgresql.org; Thu, 24 Jul 2025 15:05:17 +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 56OF5Acj1647761; Thu, 24 Jul 2025 11:05:10 -0400 From: Tom Lane To: Andrei Lepikhov cc: Michael Paquier , Sami Imseih , Greg Sabino Mullane , pgsql-hackers , Nikolay Samokhvalov , Ilia Evdokimov Subject: Re: track generic and custom plans in pg_stat_statements In-reply-to: References: <2f2bde53-972d-402c-9da3-c5467cca00bf@gmail.com> <064b9efd-92c9-4670-95f4-d911d4c7ddeb@gmail.com> Comments: In-reply-to Andrei Lepikhov message dated "Thu, 24 Jul 2025 14:25:38 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1647759.1753369510.1@sss.pgh.pa.us> Date: Thu, 24 Jul 2025 11:05:10 -0400 Message-ID: <1647760.1753369510@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andrei Lepikhov writes: > I see you have chosen a variant with a new enum instead of a pointer to > a plan cache entry. I wonder if you could write the arguments > supporting this choice? Pointing to a plan cache entry would often mean that the data structure as a whole is circular (since a plan cache entry will have a pointer to a plan). That would in particular make it unsafe for the plan to protect its pointer by incrementing the cache entry's refcount --- the assemblage could never go away. So I concur with Michael that what you propose is a bad idea. 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 replanning events. regards, tom lane