| From: | Robert Haas <rhaas(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Consider startup cost as a figure of merit for partial paths. |
| Date: | 2026-03-09 12:29:08 |
| Message-ID: | E1vzZjQ-0039O6-04@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Consider startup cost as a figure of merit for partial paths.
Previously, the comments stated that there was no purpose to considering
startup cost for partial paths, but this is not the case: it's perfectly
reasonable to want a fast-start path for a plan that involves a LIMIT
(perhaps over an aggregate, so that there is enough data being processed
to justify parallel query but yet we don't want all the result rows).
Accordingly, rewrite add_partial_path and add_partial_path_precheck to
consider startup costs. This also fixes an independent bug in
add_partial_path_precheck: commit e22253467942fdb100087787c3e1e3a8620c54b2
failed to update it to do anything with the new disabled_nodes field.
That bug fix is formally separate from the rest of this patch and could
be committed separately, but I think it makes more sense to fix both
issues together, because then we can (as this commit does) just make
add_partial_path_precheck do the cost comparisons in the same way as
compare_path_costs_fuzzily, which hopefully reduces the chances of
ending up with something that's still incorrect.
This patch is based on earlier work on this topic by Tomas Vondra,
but I have rewritten a great deal of it.
Co-authored-by: Robert Haas <rhaas(at)postgresql(dot)org>
Co-authored-by: Tomas Vondra <tomas(at)vondra(dot)me>
Discussion: http://postgr.es/m/CA+TgmobRufbUSksBoxytGJS1P+mQY4rWctCk-d0iAUO6-k9Wrg@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/8300d3ad4aa73dc6beec8dca7d9362dbc21c9a83
Modified Files
--------------
src/backend/optimizer/path/joinpath.c | 3 +
src/backend/optimizer/util/pathnode.c | 165 +++++++++++++++----------
src/include/optimizer/pathnode.h | 2 +-
src/test/regress/expected/incremental_sort.out | 28 +++--
src/test/regress/expected/join_hash.out | 13 +-
src/test/regress/sql/join_hash.sql | 10 +-
6 files changed, 133 insertions(+), 88 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Robert Haas | 2026-03-09 13:49:25 | pgsql: Replace get_relation_info_hook with build_simple_rel_hook. |
| Previous Message | Robert Haas | 2026-03-09 11:01:40 | pgsql: Prevent restore of incremental backup from bloating VM fork. |