mirror of
https://github.com/postgres/postgres.git
synced 2025-11-19 13:42:17 +03:00
Support MergeAppend plans, to allow sorted output from append relations.
This patch eliminates the former need to sort the output of an Append scan when an ordered scan of an inheritance tree is wanted. This should be particularly useful for fast-start cases such as queries with LIMIT. Original patch by Greg Stark, with further hacking by Hans-Jurgen Schonig, Robert Haas, and Tom Lane.
This commit is contained in:
@@ -1611,8 +1611,8 @@ exprs_known_equal(PlannerInfo *root, Node *item1, Node *item2)
|
||||
* Search for EC members that reference (only) the parent_rel, and
|
||||
* add transformed members referencing the child_rel.
|
||||
*
|
||||
* We only need to do this for ECs that could generate join conditions,
|
||||
* since the child members are only used for creating inner-indexscan paths.
|
||||
* Note that this function won't be called at all unless we have at least some
|
||||
* reason to believe that the EC members it generates will be useful.
|
||||
*
|
||||
* parent_rel and child_rel could be derived from appinfo, but since the
|
||||
* caller has already computed them, we might as well just pass them in.
|
||||
@@ -1631,10 +1631,14 @@ add_child_rel_equivalences(PlannerInfo *root,
|
||||
ListCell *lc2;
|
||||
|
||||
/*
|
||||
* Won't generate joinclauses if const or single-member (the latter
|
||||
* test covers the volatile case too)
|
||||
* If this EC contains a constant, then it's not useful for sorting
|
||||
* or driving an inner index-scan, so we skip generating child EMs.
|
||||
*
|
||||
* If this EC contains a volatile expression, then generating child
|
||||
* EMs would be downright dangerous. We rely on a volatile EC having
|
||||
* only one EM.
|
||||
*/
|
||||
if (cur_ec->ec_has_const || list_length(cur_ec->ec_members) <= 1)
|
||||
if (cur_ec->ec_has_const || cur_ec->ec_has_volatile)
|
||||
continue;
|
||||
|
||||
/* No point in searching if parent rel not mentioned in eclass */
|
||||
|
||||
Reference in New Issue
Block a user