diff options
author | Richard Guo | 2025-07-08 01:21:44 +0000 |
---|---|---|
committer | Richard Guo | 2025-07-08 01:21:44 +0000 |
commit | 55a780e9476a753354a6db887e92125c7886ca6d (patch) | |
tree | c91b46c31cef48c02084240d46bc3b44d5e728ba /src/include | |
parent | 7376e6085468054328a66e8c10c007bdaaf88f91 (diff) |
Consider explicit incremental sort for Append and MergeAppend
For an ordered Append or MergeAppend, we need to inject an explicit
sort into any subpath that is not already well enough ordered.
Currently, only explicit full sorts are considered; incremental sorts
are not yet taken into account.
In this patch, for subpaths of an ordered Append or MergeAppend, we
choose to use explicit incremental sort if it is enabled and there are
presorted keys.
The rationale is based on the assumption that incremental sort is
always faster than full sort when there are presorted keys, a premise
that has been applied in various parts of the code. In addition, the
current cost model tends to favor incremental sort as being cheaper
than full sort in the presence of presorted keys, making it reasonable
not to consider full sort in such cases.
No backpatch as this could result in plan changes.
Author: Richard Guo <[email protected]>
Reviewed-by: Andrei Lepikhov <[email protected]>
Reviewed-by: Robert Haas <[email protected]>
Discussion: https://postgr.es/m/CAMbWs4_V7a2enTR+T3pOY_YZ-FU8ZsFYym2swOz4jNMqmSgyuw@mail.gmail.com
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/optimizer/cost.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/include/optimizer/cost.h b/src/include/optimizer/cost.h index d397fe27dc1..b523bcda8f3 100644 --- a/src/include/optimizer/cost.h +++ b/src/include/optimizer/cost.h @@ -118,7 +118,7 @@ extern void cost_incremental_sort(Path *path, Cost input_startup_cost, Cost input_total_cost, double input_tuples, int width, Cost comparison_cost, int sort_mem, double limit_tuples); -extern void cost_append(AppendPath *apath); +extern void cost_append(AppendPath *apath, PlannerInfo *root); extern void cost_merge_append(Path *path, PlannerInfo *root, List *pathkeys, int n_streams, int input_disabled_nodes, |