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 1uhNWs-00Dten-FM for pgsql-hackers@arkaria.postgresql.org; Thu, 31 Jul 2025 07:16:43 +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 1uhNWr-00E6ht-Gf for pgsql-hackers@arkaria.postgresql.org; Thu, 31 Jul 2025 07:16:41 +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 1uhNWr-00E6hl-6l for pgsql-hackers@lists.postgresql.org; Thu, 31 Jul 2025 07:16:41 +0000 Received: from mail.postgrespro.ru ([93.174.132.70]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1uhNWp-001gay-0m for pgsql-hackers@postgresql.org; Thu, 31 Jul 2025 07:16:40 +0000 Received: from [192.168.15.242] (unknown [80.251.191.198]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: a.lepikhov@postgrespro.ru) by mail.postgrespro.ru (Postfix/587) with ESMTPSA id AE53B60B50; Thu, 31 Jul 2025 10:16:36 +0300 (MSK) Message-ID: <84510f52-ffc1-4e27-a906-883f4bd777c7@gmail.com> Date: Thu, 31 Jul 2025 09:16:35 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: track generic and custom plans in pg_stat_statements To: Michael Paquier , Sami Imseih Cc: Tom Lane , Greg Sabino Mullane , pgsql-hackers , Nikolay Samokhvalov , Ilia Evdokimov References: <1933906.1753462272@sss.pgh.pa.us> <87249b23-c4c5-4c0b-88d3-efb13b8a04d1@gmail.com> Content-Language: en-US From: Andrei Lepikhov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-KSMG-AntiPhishing: NotDetected X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.0.7854, bases: 2025/07/31 04:00:00 #27639100 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: not scanned, disabled by settings X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 31/7/2025 02:09, Michael Paquier wrote: > On Wed, Jul 30, 2025 at 03:09:08PM -0500, Sami Imseih wrote: >>> In practice, with this knowledge, we can access the CachedPlanSource of >>> the corresponding PREPARED statement via an extension and override the >>> decision made in 'auto' mode. Unfortunately, we cannot obtain a pointer >>> to plan cache entries for plans prepared by the extended protocol, but >>> this may be possible in the future. >>> >>> So, I meant that the source of the plan is one important characteristic, >>> and the type (custom or generic) is another, independent characteristic > > It seems to me that we're going to need a bit more than a design > concept here, explaining how this can be useful for core to provide > this knowledge to extensions. A lot of concepts can be defined as > "useful", but it's hard to evaluate what you'd want here and how much > it can be useful in terms of manipulations of the cached plans > depending on what you may aim for. It's also unclear up to which > extent the current state of the code would be able to help in the > concepts you're describing. Anyway, I am not inclined to have pointer > references in structures pointing to other parts of the system, just > because these can be "useful". Don't mind, I also think it wasn't a great idea to save a pointer. After the discussion, I came up with the idea that an 'extended list' in some key nodes is a much more helpful and flexible way, serving multiple purposes. Anyway, the extensibility model has never been an easy part of the system to design. So, let's think about that as a first draft approach. -- regards, Andrei Lepikhov