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 1uc1Rv-0084VN-Mj for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Jul 2025 12:41:27 +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 1uc1Rt-00A2rG-I7 for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Jul 2025 12:41:26 +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 1uc1Rt-00A2r7-4v for pgsql-hackers@lists.postgresql.org; Wed, 16 Jul 2025 12:41:25 +0000 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uc1Rr-007Zy8-1n for pgsql-hackers@postgresql.org; Wed, 16 Jul 2025 12:41:24 +0000 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-3a6f2c6715fso5114257f8f.1 for ; Wed, 16 Jul 2025 05:41:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752669682; x=1753274482; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=yHCIhPZo1X+/SY/DIrdihfNusC9ec/FIRtyeo5i93VY=; b=H0EzffMewSfj8cRdy2KyWCFnBjabaDXwDPqAAPGTB6lxO8ybsWii8ali8n1Pq1If7z qYRWg8ceAS7d/28z3WaE/3MZF1iKRcjkEIy0yLThpj785qxEN1zgr3Ep9roL/gQvLykx 1juZjFO3qRNVwziDgDBAqYqgbvFmzu+ggYYEm2ueFOFBkKzVNRVPqUlMC2tXzoo5bKIj dh/t0Fu2NKi15bv0ypKDXMzU+Xw2fy7pzMlZuA4a6aYI+mf0BrCbEqG+/8ccTDJOJHSR UjeQo0fAQif4ga/DEvJFoWXFd3nMoJR/Zh0yfLAY5JcmBPl3YV+3X4+XWIdZ0FFz76cW 3qQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752669682; x=1753274482; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yHCIhPZo1X+/SY/DIrdihfNusC9ec/FIRtyeo5i93VY=; b=SrCvsOy3NPAHMb4+K8pGsNoLdlR2kZEeWhA0coHsMXRdgYEmwQ02kXgMJFujzVZRP+ Obufgv2SW9VAX7MwLV9/HOA6sjmaABpgJaE9ZMO01QKBeKIuAqkuRNEUICdldWHg5hVP XsJiWxGZO6p5LUZQS3GsPWbmC16Hn6e38qhrC9xj5a3aH/m8YAD3bCOYIzNVz2gWGLIe rwZ2qFRQUYkeNt7iVKWgz+I5nQjbF560njFiEAv5Ucgc6RNroWGhxjF6FblenCKU+P1L vZZzOFlavzkPBWuuVPxd0/olWCn17O0FM6+klmJRXgzrRukOWBmuhhn95cRwRKZZvi4N 226A== X-Forwarded-Encrypted: i=1; AJvYcCVv7dC6qPYVcUAVBObQ7dg3TuGy9cYnaFpEVGnl8RtO/kOlDgVwcIyX3hjtNqLtllrir/3+BglokEkSMlpK@postgresql.org X-Gm-Message-State: AOJu0Yw/r/RWnN7ivscWwqzwtICTTwFZ66jqWhAQp3Qz96zAOcIF6dvS BGt6SOK4aY3ajf4yDLBFgb6r0zBhOfK96Xhbr/e48aAo9fg08WFBAiY5 X-Gm-Gg: ASbGncuUzhjWqVaQlup2bsM1RHExU6PpwpCVVWU1XZEzipP+LCZ2kxauLA7W5/cfmCC BEnWgGLRdXrDj6hVhscfg8lVAvV9OiTtO8Y8nftr+/kpLw76L/VMEbpG/xQqgw8Y8WdBMdB4BN7 sM3yYc52xHLYc4M/S1bdh7jJdsmudzkWwOKsqOUYVbk9RKITmmiEuuQvRoy50R1F/dYq5qsUuQr qP5vfxHmkp9ohwfPGZtUa2a+5N35snMkcRV78tcBd2XBC8B33pMls0XFYhVpv+QqEK2YAPMhxVq WBhw3BTDgOA90XVMIn0hF7l9tR0yL9hzYQlcNj8u9UgDBwmi0J6jUj62vpfTHI7yorRXhszhqO/ oWGe53cnuUERiRSWqq3Ru5g6OqBcgwcsYhIun0OCeTm3FbMsYcT6lRNz6 X-Google-Smtp-Source: AGHT+IEW957reZwkMIg3pJ70w5cV1V2KBosKVMNWTH4PG6ELgJlrCU2vAuX/OLV9z0qLCjw8SrqD5A== X-Received: by 2002:a05:6000:3113:b0:3a4:cb4f:ac2a with SMTP id ffacd0b85a97d-3b60e4c225fmr2033271f8f.21.1752669681739; Wed, 16 Jul 2025 05:41:21 -0700 (PDT) Received: from [192.168.0.89] (84.123.234.224.dyn.user.ono.com. [84.123.234.224]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b600a39281sm10075431f8f.73.2025.07.16.05.41.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Jul 2025 05:41:21 -0700 (PDT) Message-ID: <5f775987-8a93-452d-bb3f-a1de53836406@gmail.com> Date: Wed, 16 Jul 2025 14:41:20 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: track generic and custom plans in pg_stat_statements To: Sami Imseih Cc: Greg Sabino Mullane , pgsql-hackers , Nikolay Samokhvalov , Ilia Evdokimov References: <6f5b6a25-7391-4233-9238-7ba4f5563ef8@tantorlabs.com> <1d667f28-c739-417b-b024-7f5c1004a008@tantorlabs.com> <60f09467-bfe6-49bc-a47a-fe887050a23a@tantorlabs.com> Content-Language: en-AU From: Andrei Lepikhov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 6/30/25 13:45, Sami Imseih wrote: > rebased patch. > > Only changes to the tests due to the revert of nested query > tracking in f85f6ab051b Thank you for your efforts. I would like to share a few thoughts about this patch. First, I believe the 'status' field could be renamed to 'mode,' as it aligns better with the plan_cache_mode GUC name. Additionally, why introduce an unknown status? I can't foresee a scenario where it would be necessary, as we typically encounter either a custom or a generic plan during execution. On a more general note, currently, CachedPlanSource does not refer to a custom version of the plan. However, it seems reasonable to implement this for better tracking. By adding a CachedPlanSource::cplan link, we can establish a connection to the entire PlanCache entry instead of only CachedPlan within a queryDesc and, consequently, make it accessible from the executor. This would give an access to statistics on costs and the number of replannings. Furthermore, this could lead to interesting opportunities for extensions, such as resetting auto-mode decisions and planning statistics based on actual execution statistics, and manipulating generic/custom plan switching logic. -- regards, Andrei Lepikhov