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 1w5qkU-003guQ-1j for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Mar 2026 19:52:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w5qkR-00572V-2o for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Mar 2026 19:52:08 +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.96) (envelope-from ) id 1w5qkR-005721-1L for pgsql-hackers@lists.postgresql.org; Thu, 26 Mar 2026 19:52:07 +0000 Received: from mail-qv1-xf2d.google.com ([2607:f8b0:4864:20::f2d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w5qkQ-00000001C2a-09de for pgsql-hackers@lists.postgresql.org; Thu, 26 Mar 2026 19:52:06 +0000 Received: by mail-qv1-xf2d.google.com with SMTP id 6a1803df08f44-89a465bd7edso10835756d6.0 for ; Thu, 26 Mar 2026 12:52:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774554725; cv=none; d=google.com; s=arc-20240605; b=DT34Wl/LJ2MYaExGCMzyagXM5BcXLEQ/0mmVeFJ/YmNRB5aZAtOlk2Q5QsMeosPuSs talVsegQdL+dFJCs0UnuSpAtZ72e//CgP30WAY5Bin/k+atGnaF0YSmI4oDuNoa+zfCu aTItLAD1xznk0FEnS30TwRaAVdNPSICaYZ+mExELSTdVYkAwnkfnxo2uNAyC83uHUG60 MVVmxlqTQtdF07+X7hs+A4JSa/JkaIt5lKT5lDWDDRmRzxv9sNr4X3fafG1ssvPDgWVD 6oTKUjxtAHySSChPcOrx6UWFFAhBSD4NWmJmyHSgkV+F57+YGnST/JxebOdcyZjtoMJJ vngA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=mUz5pkSQFJRaL5QmM8D4E+Nqo1bJbunHXsR57zcEqT0=; fh=xGBe0JOH5p32itUo2Im5EQ6oNXncYSNweyJ/XNQZ6s0=; b=RulMi2UEQpYrb5FYALRCKnQ37xtZbBOXOz+b+Mr09EyMTjN0k4r+g5pxUz6JUQS4NL rDbrrdq7RV4hEInEze5KCsXgtnSDvqO5fHSufnJXdjrDrrV0F+LMn2KVbExt8ApDoMin g3jobyrM5E9X7YuWl3GLCNy3nTLbIlM5HXFtNceC4qbpI9zo1TWkmZEA+9DdaL2cSsPZ onWV9qXoJ6zBhLw7qGz3hXGcbD1srFJlOUKJOAj0iKenkAAictasgRVXCzHPhxiKQk/L QR69aNg/s917RXtdG1XE9WMaxO/kGWCOllafi0vjIxyqseIaln9TmtoSZa/whQmH7EzK VEpQ==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fittl.com; s=google; t=1774554725; x=1775159525; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=mUz5pkSQFJRaL5QmM8D4E+Nqo1bJbunHXsR57zcEqT0=; b=dlxKzYUpgI9qDRYjLgF0QRxAr8z7pnhFzpI1K4gwiZVjKtagMxutolvvOD80TYdTpR M5+FDmY8Eqrn07YEdfcWRlxrHuWswMXQKZuQDmjE7kn/9tY0JhHvYozzw42EaOOUPmt/ sHrj1faX1iBww7cg7TwHk6PPSgfY1S54/Iud0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774554725; x=1775159525; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=mUz5pkSQFJRaL5QmM8D4E+Nqo1bJbunHXsR57zcEqT0=; b=hzue60T7Skmwsy4giHRX4xYIorrmXzrjfNbBie2tgiWDCKZJFc9txTrzeIwwjLUfun CITPlUpuvTnoqktIiUbZkrh9WBJGNReBDO9W8iFnb3qzHbYRzCFksiYYdTG6Nbw1NUt1 kB29MlQpIIaqaCgVbQOftWts27/hpiv07Z/zQZvH7vb6GJedNhg0ASiSIXcTZ1Xv+kvw 4cVGcV10L++nRPSZfW655MyvC/rJW4S03NN4dxy77KC7xWjXtnwkS8pgmvCvP2pntkjn 40BzXFKly35Yt3cL/TwAH8C5lYpQufLyw0ZM/8cl46Dqm09QV2UVhZTKWm7EMmpAyr9S UqWw== X-Forwarded-Encrypted: i=1; AJvYcCWkr8I4yDD/uK7nkRgtS0q0Th7BSKcfBzQaF48QXXiIyHy7beuN1SjlE/W2cu3M8wG9igBINi0PzNBT3lJI@lists.postgresql.org X-Gm-Message-State: AOJu0YxhCLqYRByUxX0b2VeYo+BpYIClmFZk/tze8n2IdwdjWSetc4vJ h9n5sx/Ye5fNwfutTv7Ly9STny+l/5Zjcz/MliHA+moZ5iqQKP1VH7exEDAaoF/4ur79A8g34fZ tOpML6JXMwXno36dmGTOwDzbPxPTJ8EqrZEHh+gpu X-Gm-Gg: ATEYQzx6ZeI3mLUSayNWQ7nBH1KAPpun9MtJvmYqsR1DJTT9f/TTJAi/AEbRn4/ZRwc v77Kx+FFbEoNSyQzpMHg6L1G3C0TIj6fuxz+WvLMOo0twZMgdY9Vc1Rhb+NdXegp6kYh6ZkcGVs N7EEVq/S+Yqdgf405zxA/7TY6LyKG5Y8rffpsXRNdf7nXIVwdufR7xi3OTBG9JknOFFbt7jyPyy x7vqc6sJ6BzzTXD4+41VgY6CUVB8aRnsxvbkWR4MjHigWr9IC8sy6y24P19xOpUtprG1G5lsbOx maph8wAIBb3SpCvBCBvBbVojSwI2gbOvUBXsC9oCVttMl/hfsYOIEqwydtEdZtYTxX8hCZMm X-Received: by 2002:a05:6214:4285:b0:89a:1944:a696 with SMTP id 6a1803df08f44-89cc4990cddmr134456486d6.19.1774554725135; Thu, 26 Mar 2026 12:52:05 -0700 (PDT) MIME-Version: 1.0 References: <1136161.1769654478@sss.pgh.pa.us> <1299934.1773938807@sss.pgh.pa.us> In-Reply-To: From: Lukas Fittl Date: Thu, 26 Mar 2026 12:51:29 -0700 X-Gm-Features: AQROBzDARZf0JYiL04nyOaebcMcSVkJR-oi3dG5mYS3dmJcNnD-KHLmcP2MJNZg Message-ID: Subject: Re: pg_plan_advice To: Robert Haas Cc: Tom Lane , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Robert, On Thu, Mar 26, 2026 at 10:20=E2=80=AFAM Robert Haas wrote: > > The dangling pointers are a good point; I agree that's bad. However, > > I'd be more inclined to fix it by nulling out the alternative_root > > pointers at the end of set_plan_references. I think that would just be > > the case where root->isAltSubplan[ndx] && root->isUsedSubplan[ndx]. > > The reason I'm reluctant to just store the name is that there's not an > > easy way to find a PlannerInfo by name. I originally proposed an > > "allroots" list in PlannerGlobal, but we went with subplanNames on > > Tom's suggestion. I subsequently realized that this kind of stinks for > > code that is trying to use this infrastructure for anything, for > > exactly this reason, but Tom never responded and I never pressed the > > issue. But I think we're boxing ourselves into a corner if we just > > keep storing names that can't be looked up everywhere. It doesn't > > matter for the issue before us, so maybe doing as you say here is the > > right idea just so we can move forward, but I think we're probably > > kidding ourselves a little bit. > > Here's a new version, where I've replaced alternative_root by > alternative_plan_name, serving the same function. Great, I think that's better for now, and if we have a broader use case in the future we can always adjust this to be the full PlannerInfo. That said, reflecting on the change, I wonder if its odd that we're copying a string pointer instead of making an actual string copy. I think that's probably okay in practice? I'm still 50/50 on the naming here, since we have the alternative sub plan that has an "alternative plan name" that's not that of the alternative itself, but rather the base plan that was utilized. But I see your concern regarding the naming being confusing in terms of what the "original" or "base" would actually refer to. I've also considered whether something like "alternative_plan_group" could make sense (since all alternative sub plans will have the same value), but maybe that conveys too much intent on what this is used for. That said, I think for now, to get the buildfarm happy again, v23/0001 seems good. v23/0002 also looks good. Thanks, Lukas -- Lukas Fittl