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 1vqV4o-00ByfQ-0T for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Feb 2026 11:41:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vqV4n-008GM3-0i for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Feb 2026 11:41:42 +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 1vqV4m-008GLv-2u for pgsql-hackers@lists.postgresql.org; Thu, 12 Feb 2026 11:41:41 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vqV4l-00000000J3i-0SNK for pgsql-hackers@lists.postgresql.org; Thu, 12 Feb 2026 11:41:41 +0000 Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-35640ad94d3so2509992a91.1 for ; Thu, 12 Feb 2026 03:41:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1770896496; cv=none; d=google.com; s=arc-20240605; b=Xt/5pRCUSqz/luwOsJlbqq/L3kb9wvAj2Nnj/JrAfYmkoUY63ojLKnPpXmgec251ZO RKBKuu7DGbX46ZqNndyl4o0FvXT+iMH79GyU5OZMz3VryPWlA2Y0VhmG+SFxrQAwNykv geC8g0FpCt/IX2srsfk9CzFQe12Lv3uQUxIC3/4ixgW+V2Brj8bhxH7XtyrESRxWPQte CjKviPsu9FaB6CcgGBpSsAG9hLogZk9nFg/X9izXS2w1dOC+buxBarFY3/X3nQ/1NOSk n0uOjkvUBoWhvqjhnrr66EH6CEd5rt/uTpahTT9a2yQKmwubxrbjdnr1jnJcl0Z1o/O6 oR+A== 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=bV4290jN2a4Ew+4zt7FcQ28IGwtoMZaKJ88XAf14xq8=; fh=Fn55+0/RoEefvxA/x3Gx06HWf8/t1Q+gCXqJmQJRn2I=; b=R1atg88IiFXXfgaEU+dmwWUiPXrrml8nH6C3lnmkZPcmb46OehQfTCf3adjLidYzds FUhf8nuy+JVtr2MS5cdOFeKVD6b7oMeE0wK9x5P5DPkz08PCX4+9FfIqpZh54rVATPCy Hmo2clAHUxO6djq5P20rpg74tryORK0nezAgSL0VHhiwVwRcJqyChPePt3ecr9bBveU+ VL8rViSPp0VsfpMvL1PXWbNVSwyFU9aQ3OGJQ8Nj9BBU05n0/0xGy2t9dDj/tKymZAS3 WT0woRBf84JAcUtbJksfFoIPTP78HR6b/ND1I3IdmN6vbIoOlpBceT6M48r2tAljjoVY 2OoQ==; 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=20230601; t=1770896496; x=1771501296; 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=bV4290jN2a4Ew+4zt7FcQ28IGwtoMZaKJ88XAf14xq8=; b=GmXoVZas0QDNP5gZWHTSlu0vt67bTgQZ2b7QS+qdpgO9JreLXQOK55C/m1TnqlPBkA MGUy8T3BqVz6xsR5qFzXlwlEZZxCRZLcCTM289aXrlb14zsWv6OKAdaemoWS95/cyf87 046IdHQGldqA0lm7GcNkLeXjNtEnhCi0+mmLb9z+Z1nwmwzGoY0XHwQkOOxHMQyMWg7V q5+XlW24HY/rPJtUKbQnaZXMwziN31UTJf0n752umDqqtj5NiB562Wudc/DhI411CyTL 7k6WGbr9Nshh8f6HKNUmUH0R4r6Z1Ica82Fv43czU4o3T6sUm6lP80OHA36dA/REMQxD gcWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770896496; x=1771501296; 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=bV4290jN2a4Ew+4zt7FcQ28IGwtoMZaKJ88XAf14xq8=; b=s3HmUikj0J4ubp/TjsIezNqQ08n1oc5A8Y/E8ZtaYnILnoSXPPqkmCfKcSEKuk7Xm9 qxXGrGUb4kh/d8oN4BB9TVMvwhDPzeSfDQEAOn4Jk3KArj4Fp22F0wCLbuYUlXqoGb7B /7IAezmVnK2tWXgIt0n4eKJYvyHqkNv/Yt+VnUcUkd5Cl8IMvg1uXDvQXhDCtHiRpxkC SYQmyP5AFvbbDumiNmp1SF5OK9Wug3nQIgRWV6C2DOjFjtCIPgIFX5AIdd5Yeyi54OU4 UA/x5KnhzEzxH78iJaCysUjnLraJgY/CUhINQaRuIXffoaNfkLKAixxX9YQLpEXMrhqH ok5A== X-Forwarded-Encrypted: i=1; AJvYcCVNzciy4DAirufn7phZT7KTpFvUe6cMPv55cOCXQaKx3loFMTwe0vs1IUD67n/I+bZVK/gLu46BlhYUyOz/@lists.postgresql.org X-Gm-Message-State: AOJu0YzW2T9CBHgFTObD6SskLZTRS76fonohVssNCYmRMoF7eTbRKMhH Lc3jKz3c6C4lJpITiW7kwJL96Imno6htFRiMz6/2+ACMo0A1sGRywODEq0ICHXGoIaw5nQAs6hm 8mxmDKLd0q4YYtV4Q+hAaQiyFO8bouk0= X-Gm-Gg: AZuq6aKLFeplLiLZr/vPyg0pwapEbWLxVy06fj+Ju1Q6E423INUjjKQhdzdewSOugUD BQz43r5NUlB7JkULZwPs1+t6/rnisjDy1vrgCu1eubrEOukz+Ra34IV0WIUQPTxKcq4FeKJpRvo kDYy1ZX4iCEW3jUQMqda/1WzQXWpvudbEmSGMW/Flt4pPqLqLfeDmFLQBO2B7tYXA+AV+m8Ueyu iufbe7UaBrbEhqP2bFi4XdJ0DMV/0Ljchh6mRmFVgEX5vLpwhHSX7hax2ywj2u1AmgGxumhrxgq 6N01KGo+NA== X-Received: by 2002:a17:90a:e70c:b0:354:a1b8:24a6 with SMTP id 98e67ed59e1d1-35693dccd80mr1829143a91.31.1770896496517; Thu, 12 Feb 2026 03:41:36 -0800 (PST) MIME-Version: 1.0 References: <1136161.1769654478@sss.pgh.pa.us> In-Reply-To: From: Ajay Pal Date: Thu, 12 Feb 2026 17:11:25 +0530 X-Gm-Features: AZwV_Qg4bPbb-vTbuE2O-LEzA1K-T3IVLQIiu0oZQcKR6AqjrKfKL2W-p54rOL4 Message-ID: Subject: Re: pg_plan_advice To: Robert Haas Cc: Alexandra Wang , Richard Guo , Lukas Fittl , Tom Lane , Jacob Champion , Dian Fay , Matheus Alcantara , Jakub Wartak , 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, pg_plan_advice failed to match JOIN_ORDER advice because the genetic algorithm never attempts the specific join path requested. Test SQL: LOAD 'pg_plan_advice'; SET pg_plan_advice.always_explain_supplied_advice =3D on; -- Create enough tables to trigger GEQO (default threshold is 12) CREATE TABLE t1 (id int); CREATE TABLE t2 (id int); CREATE TABLE t3 (id int= ); CREATE TABLE t4 (id int); CREATE TABLE t5 (id int); CREATE TABLE t6 (id int= ); CREATE TABLE t7 (id int); CREATE TABLE t8 (id int); CREATE TABLE t9 (id int= ); CREATE TABLE t10 (id int); CREATE TABLE t11 (id int); CREATE TABLE t12 (id = int); CREATE TABLE t13 (id int); -- 1. Force GEQO on SET geqo =3D on; SET geqo_threshold =3D 12; -- 2. Run a massive join. Verify if advice is generated. EXPLAIN (COSTS OFF, PLAN_ADVICE) SELECT * FROM t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13 WHERE t1.id =3D t2.id AND t2.id =3D t3.id AND t3.id =3D t4.id AND t4.id =3D= t5.id AND t5.id =3D t6.id AND t6.id =3D t7.id AND t7.id =3D t8.id AND t8.id =3D= t9.id AND t9.id =3D t10.id AND t10.id =3D t11.id AND t11.id =3D t12.id AND t12.id =3D t13.id; --3. SET pg_plan_advice.advice =3D 'JOIN_ORDER(t13 (t5 (t12 (t1 (t6 (t9 (t11 (t10 (t2 (t7 (t4 (t8 t3))))))))))))'; --4. Run Query again Supplied Plan Advice: JOIN_ORDER(t13 (t5 (t12 (t1 (t6 (t9 (t11 (t10 (t2 (t7 (t4 (t8 t3)))))))))))) /* matched, failed */ Generated Plan Advice: JOIN_ORDER(t13 (t5 (t12 (t8 t9 t1 t10 t3 t4 t6 t7 t2 t11)))) NESTED_LOOP_PLAIN(t9 t1 t10 t3 t4 t6 t7 t2 t11) HASH_JOIN((t1 t2 t3 t4 t6 t7 t8 t9 t10 t11) (t1 t2 t3 t4 t6 t7 t8 t9 t10= t11 t12) (t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12)) SEQ_SCAN(t13 t5 t12 t8 t9 t1 t10 t3 t4 t6 t7 t2 t11) NO_GATHER(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13) Thanks Ajay On Wed, Feb 11, 2026 at 4:36=E2=80=AFAM Robert Haas = wrote: > > On Mon, Feb 9, 2026 at 10:55=E2=80=AFAM Alexandra Wang > wrote: > > On Sat, Feb 7, 2026 at 9:38=E2=80=AFAM Robert Haas wrote: > > > Here is a new patch set (v14). > > > > Thanks for the patches! 0003 - 0005 look good to me. > > I have committed those, as well as 0001 and 0002. Here's v15. The main > patch is now 0002, and has the following changes since the last > version: > > - Added a new GUC pg_plan_advice.feedback_warnings, disabled by > default, which can be set to true to produce a warning about plan > advice strings that aren't fully working. (Previously, you had to use > EXPLAIN to get this information.) > > - Use get_namespace_name_or_temp, rather than get_name_namespace, > consistently. One use of the latter function crept in, breaking > INDEX_SCAN and INDEX_ONLY_SCAN advice for temporary tables. > > - Fix a problem in pgpa_scan.c that could cause spurious NO_GATHER > advice to be generated in certain situations, such as when joins were > proven empty. > > - Fix a logic error in the handling of JOIN_ORDER advice that could > cause it to be marked as conflicting with PARTITIONWISE advice when > that was not in reality the case. > > - Incorporate documentation corrections from David G. Johnston. I > didn't take all of his suggestions, but I took many of them, sometimes > with some additional wordsmithing on my part. > > - Remove a stray comment. > > Also a reminder that 0003 and 0004 (previously 0008 and 0009) don't > properly belong to this thread, but I've included them here because > otherwise the tests in the last patch don't pass. See > http://postgr.es/m/CA+TgmobRufbUSksBoxytGJS1P+mQY4rWctCk-d0iAUO6-k9Wrg@ma= il.gmail.com > for discussion of those patches. > > -- > Robert Haas > EDB: http://www.enterprisedb.com