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 1w95x7-001BGy-12 for pgsql-hackers@arkaria.postgresql.org; Sat, 04 Apr 2026 18:42:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w95x5-0002Du-25 for pgsql-hackers@arkaria.postgresql.org; Sat, 04 Apr 2026 18:42:36 +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 1w95x5-0002DK-1A for pgsql-hackers@lists.postgresql.org; Sat, 04 Apr 2026 18:42:35 +0000 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w95x3-00000000YsM-2egk for pgsql-hackers@lists.postgresql.org; Sat, 04 Apr 2026 18:42:34 +0000 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-b9bff57cb62so456675766b.2 for ; Sat, 04 Apr 2026 11:42:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775328152; cv=none; d=google.com; s=arc-20240605; b=B2AnuaHfbmEgH/LMAg+eawV6P7iV3hK8toMjfYMvHdIE15EaebaSoJK2U7NT2yLCv3 DyU7CgoQcgDTg7WMC9+l3BMZgQL4eALJ7LLi7t4YaQCEyBeaj1/eE2XxJv4pwDvETVzS qgN4WoBuCoDxcpSKsmHabv4Pcij3kLzyPFNRjxqID8JloLiZOBTs+nCupuhksi4yOZ8I Hl/OZjdVAYFZfRWv16mAkjOC9NiUWdYUicQojKS4xcDjrjxGcgWQVDPW3uxlzifwDDLb u/IPzkPbuczNpnlyhWXsHwfTUH0Hs35ZIwHgCr60VTnUEQQGIJKY+6PO/jEkV1z4m36r G4Gg== 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=h2CPeajNJJRoDulqC4/uTIz6EuS+QhV2HTDJrnIieyw=; fh=WTQDwShozQGXEtNlhbRXvxH5J2zy0TixrZEE/of26po=; b=j8xtQ2YHGPXQ27V4ksbbi9Q2vzxGuhmVi00C9Akye+UlPa+2Wk6NwJeb+fk5UFVuSK 81rrlR03YMkR7ty6cTzOW70gt7lUoTiqfSLxzWUldz3wiuNVspjxw3JTAWsmCtd6rMpA 1iKAgjHgF03QF6OLWh8niTAwzCVIGsAaYCKy2+VRBLmFrcIYuNfIFQ4i/9+hvTUQ2D/Q SLqHyBnHsbQyd0lYArcz1socUqkEXfxbb3nCCDOk6YX/g2wSoKvi/cXOQBpWl0+nRv4a CMPFfH2jLIOBfA+72ocNCY/ZiSkttZ4SvrKjNjcvoYWxg37qyh/pgp1VtibTchrVqvR9 vTlA==; 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=gmail.com; s=20251104; t=1775328152; x=1775932952; 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=h2CPeajNJJRoDulqC4/uTIz6EuS+QhV2HTDJrnIieyw=; b=bxC9uF2EuZFvk5twoWq3ZghuH5rf6K37j2kBLb/MkwvFu7uddFsYZCUGLqBgCPTwpt 2wJq7Nk5Rzsad9GqJdB9TdQkSKfp8JrhtX60VE1qia6r8sH0LR4ArZycotM0BLk3LPtU IwyWk8n4H/YZYMkWib5CBFHg0zM2+CzoApyZnLJS4vgJQqoCQ4uCMJIfLXJI3YjiLdU0 xsjipcR3KgZa+58dYO7rdqSFK3UhiN0uppAaKrPKy+SJ1IXwDoLj7I30zRbrTqpgqC1i 79dpRoV360UwigVVtzy13/eoG2Yf2wtGr53mgFb/tKHQF/lTU0UsjSRXIosw3CUYenVQ R+Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775328152; x=1775932952; 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=h2CPeajNJJRoDulqC4/uTIz6EuS+QhV2HTDJrnIieyw=; b=ancATlh8O3BOJD7UMvJIh/e5ZdeeubJpvkTVC8fChlaVqeMn5RmTQbihVWy2vYSk+w 5Z9aEsmwaFiPWlJLAcfbKAU/MUT4PIVoH5RJlUzwGL/spSn8bK3m5z8vmpBbL5d0VYSj eh/lK6mBRWha67CJU2XoLFvlW5/ewD7Hk8vd8jKvDIEwp9/nbBsB0ggONL4mpMC06YKm v1xmWNkJwi89pOm+Bq6BJioFTMNpRkxuK8ZPIEF9wdvuv0MKWZPOyLO7+DN/tQ9s913l kZxrWc0NK+6LHtsII6w7wulrmobqY31EHagSpAk2izlQYiby3DNtW7CT54SkWRrmpccW 6G6g== X-Forwarded-Encrypted: i=1; AJvYcCVcoowe5xBYnK1YX+3QPWjiOFgWMicMQdOQ1V3cL1MhVr/PycNtfQBqXcU6TxzjpWpxKlS3FJ2jAWCyzhhH@lists.postgresql.org X-Gm-Message-State: AOJu0YxaL6Zk5AuVpzAGFr8G+FoFz6NOEpFfDMiSRRzpAKtwwiLvfbXM cEShjicR0cPY1ckTmjXQ0VzrAIXM5aJ/ICDat979rJ5jtk7dXwLIT6F60/MA1Ewr9QIq5mpdG9e +ViGZzy/QcjgwaLE28r23Fn6sOh5Gm9Y= X-Gm-Gg: AeBDiesEBhGAVndGs/6/zukJ4juZ7+pp/NFsbX+lH5cOCf4xSkZ8ZAWUkgVvUnnzct8 nFUXyESv/sIguhC9OEGIwVU0MygR+slX5JWLKkObaebo1ThTAHnrijr5etbtsgSjCpuTiCrAt8S //O6J7UkxTN2zMml+NQpw2A+jWrKWyrgc9Ukh41lFDIUmmxBDsWSm4tMxt6q8vr8zVA/q2UNqew uM1quyiq8vj5zQuebKZvLpcPWo/YTdcz5Nr4uciNuBAmLmoBFXOakbVu80o6oPlsnvVnzQa9bsV ecwXOhXX72g7MagjE3knClIbInd+tFP0QJplRh4= X-Received: by 2002:a17:906:209a:b0:b8f:f08a:4b80 with SMTP id a640c23a62f3a-b9c6742fc96mr258617466b.3.1775328151819; Sat, 04 Apr 2026 11:42:31 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: <386d8c06-0f96-40bb-b1b1-107db209c676@gmail.com> From: Robert Haas Date: Sat, 4 Apr 2026 14:42:19 -0400 X-Gm-Features: AQROBzAZ7hnHXslQdW1WyqAufE-HMad9upEL1YX-9NUaWEvfF_6fMl4_hbDdS-M Message-ID: Subject: Re: pg_plan_advice To: Andrei Lepikhov Cc: Tom Lane , Alexander Lakhin , Lukas Fittl , 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 On Sat, Apr 4, 2026 at 5:34=E2=80=AFAM Andrei Lepikhov = wrote: > As you work on the code, please keep the pg_plan_advice issue [1] in > mind. I came across it while designing the optimisation in [2]. Even if > [2] is not added to the Postgres core, this still looks like a valid > query plan and may be proposed by an extension. So, the hinting module > should avoid conflicts with other extensions, just as pg_hint_plan does. > > [1] pg_plan_advice fails when NestLoop outer side is Sort over FunctionSc= an > https://www.postgresql.org/message-id/78dd9572-7569-4025-984d-e07d7f381b6= e@gmail.com > [2] Try a presorted outer path when referenced by an ORDER BY prefix > https://www.postgresql.org/message-id/19a9265c-c441-4a43-bc0d-dac533438da= 0%40gmail.com I'll take a look at that issue when I have a free moment. We certainly cannot promise in general that pg_plan_advice will be able to make sense of plans that PostgreSQL's own planner does not produce; that would require magical code. But there might be something that can be done to ameliorate this particular instance. By the way, I'm really glad you hit that error. That particular error check is there precisely to find plans that pg_plan_advice isn't able to understand, and it sounds like it is doing its job as intended. Having problems isn't great, but knowing that you have problems is a lot better than still having them but not knowing about it. --=20 Robert Haas EDB: http://www.enterprisedb.com