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 1vVrqJ-009GCY-10 for pgsql-hackers@arkaria.postgresql.org; Wed, 17 Dec 2025 13:45:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vVrpI-00D3FS-0j for pgsql-hackers@arkaria.postgresql.org; Wed, 17 Dec 2025 13:44:25 +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 1vVrpH-00D3FK-2a for pgsql-hackers@lists.postgresql.org; Wed, 17 Dec 2025 13:44:24 +0000 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vVrpG-0019aH-0q for pgsql-hackers@lists.postgresql.org; Wed, 17 Dec 2025 13:44:22 +0000 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-5945510fd7aso4895297e87.0 for ; Wed, 17 Dec 2025 05:44:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1765979055; x=1766583855; 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=L2HN7mQ3LdB3k6g63QhlFg97K3984j4Lsid4tXpWicI=; b=DV0h+75cDsEitSwKQkzCh6trAPrU7k2vm5ypbgEIksmS+nDzPJXWYDvNbzWfsuzlP0 20r/GToD5XAApHKY9OhwORAaa5s5syOi22brhS2q5DNzdGdUazeVgcIR5O5DfEoFXuMg d8MH8KQj8CKlQdZqOFpzOlIud70z3jk18HAGoClof7Q8qbwa3yst/gX8JL3Hr+zTEubq 0MiiFH/elRQS+gWu4lWUkTLGASeDdYOCn+ccbmJBRlnqdEkEmFbZx+s8fPkEo9qUiVzk NRiT3bw9ENIsEvkfps9n//hE1YTBqwOFbjhtYEAkjrvDAA7FZaFEedlzVpsaNtn8tY80 iMrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765979055; x=1766583855; 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=L2HN7mQ3LdB3k6g63QhlFg97K3984j4Lsid4tXpWicI=; b=iPdIF04p7Bf8Arw6sVm2gnR/WdSAYUKZWE3rWpnUK/5qwKULzCev2ZZtFmZ+XbKZS+ 5ZC5rCxkHBkpqL4remIKhyM9J7zKYzVtVqmXmZbhoYGSfraiXBnlFUvme4ujx+Y8kQ01 T7uHiNKbx/V0wQQlQSKWh+fEQ9UkrNQP28IFD652nTkVTLDU/Nwta3VZuRcbb+y9ooZ2 P+zV/EAzSiUueYuyDWa19DTRiOjihVsJHqjgW4hrQOHXkWrtgDLzxkyuUXBmvnxPP1Gl Bw2ruMH7yPjVHKUROZeZYS8mJ2yV8sUW0UT0N44KBe8piBiM8X/KIsIFQVC4VgY/JJfe Tndw== X-Forwarded-Encrypted: i=1; AJvYcCWToYKjX7QF6TARNiOgPs/UutufXjwrv2WwPUJ3qJcqc3NwNjD3yhM+q2Ictw2bKZzkKoYh2MtlHgYpD2Ed@lists.postgresql.org X-Gm-Message-State: AOJu0YzpYG2+MY6MxJ2CdOQRkYAGq6JM7RTX48Irkr7w1Ad3wj+wvKbT yFsYj66rQF9NPv7KQ/+jx48btwBXIZ1g4HmTe0RgoT7g9M1nIksVHn5dxKvWTSwu5EC81KvmLHn 8ja67D2NVeqf15Ingx+tZP4AFhcrEB00m2E7sCL8Q X-Gm-Gg: AY/fxX4N8kBhksSf0ACJmP4nsVxDPe9vrI5U65XGCNNeAGs8TJGJCbpUNLr+5eMHuYO aumNLbyhZZTOuGW+knVRALo7ZzTOlwzNF/1mQrMV8DnzUQQ3WJIi2zT88aCovw+aL9GI8Whn4zH e6gsv1A6N/cVzOylTw5T4rN3bnG38SwGAdAdJKSfMBj6NIbT1NIlrtqNKnXXTvVI2s5To+58Rmk 2FhJobD79WmjZ5w+KHe4DyzGMrNLdahRPweuEhRKQg/s27xlXE8RhCggWD3NOFWuJE+AW8= X-Google-Smtp-Source: AGHT+IHOkRkSqQlgcYvYpA7jx+CIcp6koNvf84UC2u/CyPHBF2BVVPpd18QliSkuPmLVwTiYnDeNUirFvWWBu3PUI1w= X-Received: by 2002:a05:6512:39cb:b0:594:cb92:b377 with SMTP id 2adb3069b0e04-598faa8fd8cmr6553223e87.42.1765979054968; Wed, 17 Dec 2025 05:44:14 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Jakub Wartak Date: Wed, 17 Dec 2025 14:44:02 +0100 X-Gm-Features: AQt7F2pzuhlYdK0hlRbD7uwp6yPyUoRYaRKxnK23iAcO-f98xLfwVaPjauyesKM Message-ID: Subject: Re: pg_plan_advice To: Robert Haas Cc: Jacob Champion , Dian Fay , Matheus Alcantara , 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 Wed, Dec 17, 2025 at 11:12=E2=80=AFAM Jakub Wartak wrote: > > On Mon, Dec 15, 2025 at 9:06=E2=80=AFPM Robert Haas wrote: > > > > Here's v7. > [..] >[..q20..] OK, now for the q10: Sort Sort Key: (sum((lineitem.l_extendedprice * ('1'::numeric - lineitem.l_discount)))) DESC -> Finalize GroupAggregate Group Key: customer.c_custkey, nation.n_name -> Gather Merge Workers Planned: 2 -> Partial GroupAggregate Group Key: customer.c_custkey, nation.n_name -> Sort Sort Key: customer.c_custkey, nation.n_name -> Hash Join Hash Cond: (customer.c_nationkey =3D nation.n_nationkey) -> Parallel Hash Join Hash Cond: (orders.o_custkey =3D customer.c_custkey) -> Nested Loop -> Parallel Seq Scan on order= s Filter: ((o_orderdate >=3D '1993-10-01'::date) AND (o_orderdate < '1994-01-01 00:00:00'::timestamp without time zone)) -> Index Scan using lineitem_l_orderkey_idx_l_returnflag on lineitem Index Cond: (l_orderkey =3D orders.o_orderkey) -> Parallel Hash -> Parallel Seq Scan on custo= mer -> Hash -> Seq Scan on nation Generated Plan Advice: JOIN_ORDER(orders lineitem customer nation) NESTED_LOOP_PLAIN(lineitem) HASH_JOIN(customer nation) SEQ_SCAN(orders customer nation) INDEX_SCAN(lineitem public.lineitem_l_orderkey_idx_l_returnflag) GATHER_MERGE((customer orders lineitem nation)) but when set the advice it generates wrong NL instead of expected Parallel HJ (so another way to fix is to simply disable PQ, yuck), but: Sort Sort Key: (sum((lineitem.l_extendedprice * ('1'::numeric - lineitem.l_discount)))) DESC -> Finalize GroupAggregate Group Key: customer.c_custkey, nation.n_name -> Gather Merge Workers Planned: 2 -> Partial GroupAggregate Group Key: customer.c_custkey, nation.n_name -> Sort Sort Key: customer.c_custkey, nation.n_name -> Nested Loop -> Hash Join Hash Cond: (customer.c_nationkey =3D nation.n_nationkey) -> Parallel Hash Join Hash Cond: (orders.o_custkey =3D customer.c_custkey) -> Parallel Seq Scan on order= s Filter: ((o_orderdate >=3D '1993-10-01'::date) AND (o_orderdate < '1994-01-01 00:00:00'::timestamp without time zone)) -> Parallel Hash -> Parallel Seq Scan on customer -> Hash -> Seq Scan on nation -> Index Scan using lineitem_l_orderkey_idx_l_returnflag on lineitem Index Cond: (l_orderkey =3D orders.o_orderkey) Supplied Plan Advice: SEQ_SCAN(orders) /* matched */ SEQ_SCAN(customer) /* matched */ SEQ_SCAN(nation) /* matched */ INDEX_SCAN(lineitem public.lineitem_l_orderkey_idx_l_returnflag) /* matched */ JOIN_ORDER(orders lineitem customer nation) /* matched, conflicting, failed */ NESTED_LOOP_PLAIN(lineitem) /* matched, conflicting */ HASH_JOIN(customer) /* matched, conflicting */ HASH_JOIN(nation) /* matched, conflicting */ GATHER_MERGE((customer orders lineitem nation)) /* matched */ So to me it looks like in Generated Plan Advice we: - have proper HASH_JOIN(customer nation) - but it somehow forgot to include "HASH_JOIN(orders)" to cover for that Parallel Hash Join on (orders.o_custkey =3D customer.c_custkey) with input from NL. After adding that manually, it achieves the same input plan properly. Please let me know if I'm wrong, I was kind of thinking Parallel is not fully supported, but README/tests seem to state otherwise. -J.