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.96) (envelope-from ) id 1w9IMD-001KNk-1O for pgsql-hackers@arkaria.postgresql.org; Sun, 05 Apr 2026 07:57:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w9IMB-001xHU-2z for pgsql-hackers@arkaria.postgresql.org; Sun, 05 Apr 2026 07:57:20 +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.96) (envelope-from ) id 1w9IMB-001xHM-26 for pgsql-hackers@lists.postgresql.org; Sun, 05 Apr 2026 07:57:20 +0000 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w9IM9-00000000h7N-37bs for pgsql-hackers@lists.postgresql.org; Sun, 05 Apr 2026 07:57:19 +0000 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-43cfd832155so1810704f8f.1 for ; Sun, 05 Apr 2026 00:57:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775375835; x=1775980635; darn=lists.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=zQS1n90A3UJ9/zTD9bBK/01JirucxIkbZGaVXVLQxnQ=; b=H4DjioV7Mt1TUJtmIlqaPxHo8QPzwIqwvCs2W+4RkxRhbTgacD2IHWrCRs22tR3g39 ev2MwdM6SjtHSGuIpthBrpbP6T54b7kHyCfBHpl1O62aPNUJSlZWknNQXOx4FJs7rYQr BppQytqdNCs2R/iirdakTu0lUI79MG0tH7mKFQA7XsMXQ/K0LVuRzwb2Hb+ViQyNy/C7 x+bA44tqBYY0PSHbBvO8/+ffWyiZ3YtakOsf7fnGN9C9G6GdoAqaILnLzMh69ezWqKqV js8/hrJcImUybJHGEGhK80Wj0Tu9FeqZD1EtEoDK4W4r0cvCixHYBgcRAK/N9tNnOCoN JmLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775375835; x=1775980635; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zQS1n90A3UJ9/zTD9bBK/01JirucxIkbZGaVXVLQxnQ=; b=SF8pKp127H245nJyulUxlgkIzpQFmNhJ01qyyDF7VE7yDgVpYoHGYbtV+NPqYEnH/E yapciwIeIGJqpQGJhQqd1fL1lr2MlmRJGIjRnKU4EHNizyZlUofhjX0OscoH9N1cuR17 rVpB7bXMi16xL/Fu6BS35d5m3bjAa/auLn10i2Yw6tkH/GwhKiJ8DasQ/12ihXhSWpeo CjQh2IfYpimn1Mn9ueKvvSj1AwH2MBHX2Ixb+QnDe5wqENEh+uKrQorKy1f5VZMsWl7P bx69D3iihIbnS4QPN5Liyg1EQhSRRspU7GEINCgPkqsAnVZMQIutHhicd+TlPVg7jxuk oYaw== X-Forwarded-Encrypted: i=1; AJvYcCXci8SW6WhFcfJftJWpDI5Dft5kenFCdvZ2awtwzXx/swboFpBS7amSTcPPfJaEaCChavgyWfWcdFUjsbSg@lists.postgresql.org X-Gm-Message-State: AOJu0YwjQO/l0RrM2LyBhr0sPNVJB2FVGjHmLQrazUjW1V1/XIF8XNUc ygST+fgCOtiI63LN9JsLAegiyNkNhrFGAHZ3ejGTvXD+ui373lvqlT+Ao02Spw== X-Gm-Gg: AeBDieuy+r5PchcIyi4wR52rPPpMtSjv6YfxLwoK/aTO9Qk4If4pAsSDWDuzPTvdUS0 M8ZO3kVcns69Rklb4jzBrZudEnlzHxgRV1OsgxUjhcI+XLE1eKzFRgIWgvVyevFrEIaoZMS9Rha 69hIa/DMr3h2U0ICHHIvkdQJNmN42EM/58xSRQ1/eLvfC8BfoImet5JrI9R+iVxyCdtNuIuGfIl Nz7QXBpAjlOBIg6XddtXd2JFWBqnTr1k95kRsXSWJAhXqOh+zOpwpmCUzXnE7M30r9dcF43v9lw oNLaE4wlDEpARqGUccqgt0E7cmUeIgP3YTa1hHuVsSkuBlbSIztP42N/A34nVi1cbuKrS3ufytX rmdk+4E64ClDlxJk+/jXKsVwWBpvfloIiL5nsC1/JShcwVwe+0oKkp7CTaBzxU2hhD2EJbH/YQZ soM/LRJlOK3eYY5dZT9fmuCRfxS295PfoXB/XjMwS/a9CRqgNX3kDEyFJnBp77VebqiHf/fxcwU M70mUXl9A== X-Received: by 2002:a5d:64e6:0:b0:43c:fdd:ea96 with SMTP id ffacd0b85a97d-43d292e3ad2mr13152992f8f.26.1775375835150; Sun, 05 Apr 2026 00:57:15 -0700 (PDT) Received: from [192.168.0.86] (84.123.226.31.dyn.user.ono.com. [84.123.226.31]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43d1e2a71f7sm32370871f8f.1.2026.04.05.00.57.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 05 Apr 2026 00:57:14 -0700 (PDT) Message-ID: Date: Sun, 5 Apr 2026 09:57:13 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: pg_plan_advice To: Robert Haas Cc: Tom Lane , Alexander Lakhin , Lukas Fittl , PostgreSQL Hackers References: <3683430.1775173413@sss.pgh.pa.us> <3817825.1775240432@sss.pgh.pa.us> <3877210.1775272486@sss.pgh.pa.us> <386d8c06-0f96-40bb-b1b1-107db209c676@gmail.com> <2e7bdb5d-68ba-4c65-9931-a865ab6fc3d2@gmail.com> Content-Language: en-US From: Andrei Lepikhov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 5/4/26 00:52, Robert Haas wrote: > On Sat, Apr 4, 2026 at 5:02 PM Andrei Lepikhov wrote: >> That’s exactly what concerns me. I see it as a potential design flaw if >> the extension has to make assumptions about possible plan configurations. >> I’m not sure how it works in detail, of course. However, when I designed >> Postgres replanning in the past, and made similar core changes to what >> you’ve done for pg_plan_advice, this kind of problem couldn’t have >> happened. So, I think it’s worth questioning the current approach and >> looking for other options. > > I mean, any plan stability feature is intrinsically tied to a > particular planner. Nobody thinks you can use Aurora Postgres's Query > Plan Management feature with MySQL or DB2 or Oracle. Those products I don’t expect any Postgres extension to work in DB2. These optimisations are simple. Here, I provided the optimiser with one extra path that it skipped itself just to reduce computational overhead - nice in the general case, but not ok in analytics. This extension of planning scope allowed the optimiser to build JOIN over the Sort operator, which didn’t change the main logic at all. I followed the usual cost-based model and used add_path. Another optimisation improves Memoize so it can run on top of SubPlan when the cost model predicts many repeated parameter values. One more extension uses MergeJoin estimation on the required values of its inputs to determine how many tuples are needed from each input, which adds kinda 'soft' LIMIT emerged from the plan structure ... The Append node serves as the backbone of any partitioning or sharding setup, but contributors often overlook it, and we use multiple extra optimisations here too. There’s a lot to say about branched out-of-core optimisations infrastructure, but it’s clear that supporting analytical workloads means adding extra features. Developers usually stick to standard Postgres practices, cost model and routines providing the planner with alternatives without forcing any 'magical' paths. So, they expect built-in extensions not to interfere with their code by design. Looking back at the pg_plan_advice development cycle, I don’t see many discussions about the design. It seems unusual given how complex the planner's structure is. It makes sense to follow the typical way and let it serve out of the contrib for some time and see if it works well. Introducing such a module into the core would effectively cancel alternative solutions, as seen with PGSS. Therefore, it is important to ensure the code is well-designed before proceeding. Do you agree? -- regards, Andrei Lepikhov, pgEdge