Re: Consider low startup cost in add_partial_path

Richard Guo <guofenglinux@gmail.com>

From: Richard Guo <guofenglinux@gmail.com>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Tomas Vondra <tomas@vondra.me>, James Coleman <jtc331@gmail.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2026-02-17T07:44:39Z
Lists: pgsql-hackers
On Sat, Feb 7, 2026 at 6:06 AM Robert Haas <robertmhaas@gmail.com> wrote:
> I rediscovered this problem while testing pg_plan_advice, and I think
> we should commit something to fix it.

Yeah, I agree that we should consider startup cost for partial paths,
given that cost_gather (and cost_gather_merge) accounts for the
subpath's startup_cost when calculating the cost of the Gather path.

The changes LGTM.  I noticed one comment that may need to be updated
accordingly:

 *    As in add_path, the partial_pathlist is kept sorted with the cheapest
 *    total path in front. ...

This is not true anymore.  The partial_pathlist is now sorted by
disabled_nodes and then by cheapest total cost.

- Richard



Commits

  1. Consider startup cost as a figure of merit for partial paths.

  2. Fix add_partial_path interaction with disabled_nodes

  3. Support parallel joins, and make related improvements.