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 1vdsY8-0065Lo-1k for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Jan 2026 16:07:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vdsY7-0033Nt-1e for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Jan 2026 16:07:48 +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 1vdsY7-0033Nk-0d for pgsql-hackers@lists.postgresql.org; Thu, 08 Jan 2026 16:07:47 +0000 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vdsY6-004udD-0i for pgsql-hackers@lists.postgresql.org; Thu, 08 Jan 2026 16:07:46 +0000 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-b7a6e56193cso568320966b.3 for ; Thu, 08 Jan 2026 08:07:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767888464; x=1768493264; 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=rV6Y5p60UZ40VBq9TXQR2xg9u9qoxd9ofg5ZAApxOrM=; b=fQJG6tweQktTGq95tJPfYr1e57fJwwIGMV30gh1g9jZf9n7ONiqQh3FQtVa7dGftDb j7F3HdXhJRMtnievEN9rXt84SJh3cYBfSniqJo6V+qK8LedbJ2tNsrKzZnH0oRaFGtAM ZySKnjX9SVIZXqTeFyIGWQRWBE6LYf6Ad6cWJKEzCoqeS3+Exl3VwX9lCSVeZZtwTPZ2 rvI5MsKr3UGLn5ACDX5+XW4zPFYH4/LurWjC9RBXcnrTFje3fXnWPUzS2h35CKcSpGeq 4I34dagi10scxw2LxuiKLP8OTeH8x9DCW1IDBnnAxVxofrqT/d/P/uqHGIZcncGMg03j 2czw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767888464; x=1768493264; 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=rV6Y5p60UZ40VBq9TXQR2xg9u9qoxd9ofg5ZAApxOrM=; b=DVaiWz4L3/GlcAf6Napk94ggLeAhfDU5zq4v0vM4aWOWtTHDfY5BOoXqAXuzJEZHtt E/FgCzKOI3gIANpfGkBIJ6TGPTrwfPweLRTScshc+H83uAY1a9vJsTZQJvAa+J9Ke1l1 Dcb27J/ipHplpvD2aN6XzgIxIRKoW4h7p8OQjDsbXvW2MWxVrzxdjcD3f6ZmHWMJO74k sAfx9ZeV2jrmvLuYStFGRhfdULjhRFYES0NNHMSNHTw4LuxYf9WgntzuScqf6z/ciLV4 iSEfvRoWFLY6d/TqVnEVEBp9TKbGOFKQ58OQp08ur2SUXlU9S0U9tuRbxamuoCHOiXuG G00Q== X-Forwarded-Encrypted: i=1; AJvYcCVU7HvQjHZo+Tp/FaO1w43U6HoK90uVTKWg/dj8uZu9Hm7BfeIZayMX5OOnH7HLyzxzEB4r8x6OjazHQIwS@lists.postgresql.org X-Gm-Message-State: AOJu0YxStUbGTuegOnHT2zyF4AGTDqddiJnNkgegwLLykNf8uX559A7k YMPv28SEmXsBnL1KnEzgNdlxnBNzBfZnJXDZXp+TRhsDoyg908piAh6SxNKzC2C6J5NbgMV/G6Z GFOKNNjeoh24yvYa8sJW4pJi02ooyuHkqEPAJ X-Gm-Gg: AY/fxX5VeKHJzL1zohE0eVWa7xYwDq5Hc1fqpXnXRWvO5uqTkm2QS8Ptux23wF556bf 4pNAYumqQo8tQ0QI6odx8WUDN4Ln6sP31eIKNIp73DC416NcdlhZO9JDptkygygTtfHPMp7+xKe 0je+AJ/ZfnaoNFnpkZ4H+BoNTc7hQIDhtiz7dVfjeBOpU0W8BlqwKPyYEZ/l1WHDc/TPRDyy9Uf xVheXgwVs+NHhzixMQv6EoyQ7lyxLtx3BxJt3A9ztmcEjQS2KNuqLv6K0PQwWoQNxJqCtYFLmwy ccrDG4+kyxBQx7DVgG7MCAnCa0s= X-Google-Smtp-Source: AGHT+IH8pdytFlnd549iZGGi8EqBoaySOQfZUCR8XYnJU3YqZ8nPEGMY8WAyJhgkN2VjU90R1eqE12SEDm/8sDcKIic= X-Received: by 2002:a17:907:2da6:b0:b72:134a:48c8 with SMTP id a640c23a62f3a-b8445232b14mr646726966b.14.1767888463965; Thu, 08 Jan 2026 08:07:43 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Robert Haas Date: Thu, 8 Jan 2026 11:07:31 -0500 X-Gm-Features: AQt7F2q5ByhnQ2LwkP0oS3GeIrw17LkSmHHKzF5POvgDOImrgb3RKFMVv9UYHg8 Message-ID: Subject: Re: pg_plan_advice To: Lukas Fittl Cc: Jacob Champion , Dian Fay , Matheus Alcantara , Jakub Wartak , PostgreSQL Hackers , Michael Paquier 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, Jan 7, 2026 at 2:04=E2=80=AFAM Lukas Fittl wrote: > That said, good news: After a bunch of iterations, I get a clean pass on = the pg_hint_plan regression tests, > whilst completely dropping its copying of core code and hackish re-run of= set_plain_rel_pathlist. See [0] > for a draft PR (on my own fork of pg_hint_plan) with individual patches t= hat explain some regression test > differences. That sounds AWESOME. > The biggest change in the regression test output was due to how the "Para= llel" hint worked in pg_hint_plan > (basically it was setting parallel_*_cost to zero, and then messed with t= he gucs that factor into > compute_parallel_worker) -- I think the only sensible thing to do is to c= hange that in pg_hint_plan, and > instead rely on rejecting non-partial paths with PGS_CONSIDER_NONPARTIAL = if "hard" enforcement of > parallelism is requested. That caused some minor plan changes, but I thin= k they can still be argued to be > matching the user's intent of "make a scan involving this relation parall= el". Cool. I'm sort of curious what changed, but maybe it's not important enough to spend time discussing right now. > There were two bugs in 0004 that I had to fix to make this work: > > In cost_index, we are checking "path->path.parallel_workers =3D=3D 0", bu= t parallel_workers only gets > set later in the function, causing the PGS_CONSIDER_NONPARTIAL mask to no= t be applied. Replacing > this with checking the "partial_path" argument instead makes it work. I agree that this is a bug. I'm thinking this might be the appropriate fix: enable_mask =3D (indexonly ? PGS_INDEXONLYSCAN : PGS_INDEXSCAN) - | (path->path.parallel_workers =3D=3D 0 ? PGS_CONSIDER_NONPARTIAL = : 0); + | (partial_path ? 0 : PGS_CONSIDER_NONPARTIAL); > In cost_samplescan, we set the PGS_CONSIDER_NONPARTIAL mask if its a non-= partial path, but that > causes Sample Scans to always be disabled when setting PGS_CONSIDER_NONPA= RTIAL on the > relation. I think we could simply drop that check, since we never generat= e partial sample scan paths. This one is less obvious to me. I mean, if PGS_CONSIDER_NONPARTIAL lets us consider non-partial plans, and a sample scan is a non-partial plan, then shouldn't the flag need to be set in order for us to consider it? If not, maybe we need to rethink the name or the semantics of that bit in some way. --=20 Robert Haas EDB: http://www.enterprisedb.com