diff options
author | Tomas Vondra <tomas.vondra@postgresql.org> | 2020-12-22 02:00:39 +0100 |
---|---|---|
committer | Tomas Vondra <tomas.vondra@postgresql.org> | 2020-12-22 02:01:42 +0100 |
commit | 336879f5557e6bb1f6c8d7837fd8b87158441078 (patch) | |
tree | d90dd6ad4d5e0cc9e73765f1d3872a7792b5522e /src | |
parent | aa97890b6ec2ad07700c6e4825022ae3979ece7f (diff) | |
download | postgresql-336879f5557e6bb1f6c8d7837fd8b87158441078.tar.gz postgresql-336879f5557e6bb1f6c8d7837fd8b87158441078.zip |
Improve find_em_expr_usable_for_sorting_rel comment
Clarify the relationship between find_em_expr_usable_for_sorting_rel and
prepare_sort_from_pathkeys, i.e. what restrictions need to be shared
between those two places.
Author: James Coleman
Reviewed-by: Tomas Vondra
Backpatch-through: 13
Discussion: https://postgr.es/m/CAAaqYe8cK3g5CfLC4w7bs%3DhC0mSksZC%3DH5M8LSchj5e5OxpTAg%40mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/optimizer/path/equivclass.c | 8 | ||||
-rw-r--r-- | src/backend/optimizer/plan/createplan.c | 3 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/backend/optimizer/path/equivclass.c b/src/backend/optimizer/path/equivclass.c index 1e151dd510c..b93c11155c7 100644 --- a/src/backend/optimizer/path/equivclass.c +++ b/src/backend/optimizer/path/equivclass.c @@ -795,9 +795,11 @@ find_em_expr_for_rel(EquivalenceClass *ec, RelOptInfo *rel) } /* - * Find an equivalence class member expression that can be safely used by a - * sort node on top of the provided relation. The rules here must match those - * applied in prepare_sort_from_pathkeys. + * Find an equivalence class member expression that can be safely used to build + * a sort node using the provided relation. The rules are a subset of those + * applied in prepare_sort_from_pathkeys since that function deals with sorts + * that must be delayed until the last stages of query execution, while here + * we only care about proactive sorts. */ Expr * find_em_expr_usable_for_sorting_rel(PlannerInfo *root, EquivalenceClass *ec, diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index b3ab169f78c..84f2d186d95 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -5844,6 +5844,9 @@ make_incrementalsort(Plan *lefttree, int numCols, int nPresortedCols, * * Returns the node which is to be the input to the Sort (either lefttree, * or a Result stacked atop lefttree). + * + * Note: Restrictions on what expressions are safely sortable may also need to + * be added to find_em_expr_usable_for_sorting_rel. */ static Plan * prepare_sort_from_pathkeys(Plan *lefttree, List *pathkeys, |