Consider startup cost as a figure of merit for partial paths.
Robert Haas <rhaas@postgresql.org>
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@postgresql.org> Co-authored-by: Tomas Vondra <tomas@vondra.me> Discussion: http://postgr.es/m/CA+TgmobRufbUSksBoxytGJS1P+mQY4rWctCk-d0iAUO6-k9Wrg@mail.gmail.com
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/optimizer/path/joinpath.c | modified | +3 −0 |
| src/backend/optimizer/util/pathnode.c | modified | +102 −63 |
| src/include/optimizer/pathnode.h | modified | +1 −1 |
| src/test/regress/expected/incremental_sort.out | modified | +15 −13 |
| src/test/regress/expected/join_hash.out | modified | +7 −6 |
| src/test/regress/sql/join_hash.sql | modified | +5 −5 |
Discussion
- Consider low startup cost in add_partial_path 15 messages · 2019-09-27 → 2026-03-09