Skip to content

Commit 1ca2eb1

Browse files
committed
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
1 parent 9aff4dc commit 1ca2eb1

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/backend/optimizer/path/equivclass.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -798,9 +798,11 @@ find_em_expr_for_rel(EquivalenceClass *ec, RelOptInfo *rel)
798798
}
799799

800800
/*
801-
* Find an equivalence class member expression that can be safely used by a
802-
* sort node on top of the provided relation. The rules here must match those
803-
* applied in prepare_sort_from_pathkeys.
801+
* Find an equivalence class member expression that can be safely used to build
802+
* a sort node using the provided relation. The rules are a subset of those
803+
* applied in prepare_sort_from_pathkeys since that function deals with sorts
804+
* that must be delayed until the last stages of query execution, while here
805+
* we only care about proactive sorts.
804806
*/
805807
Expr *
806808
find_em_expr_usable_for_sorting_rel(PlannerInfo *root, EquivalenceClass *ec,

src/backend/optimizer/plan/createplan.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5850,6 +5850,9 @@ make_incrementalsort(Plan *lefttree, int numCols, int nPresortedCols,
58505850
*
58515851
* Returns the node which is to be the input to the Sort (either lefttree,
58525852
* or a Result stacked atop lefttree).
5853+
*
5854+
* Note: Restrictions on what expressions are safely sortable may also need to
5855+
* be added to find_em_expr_usable_for_sorting_rel.
58535856
*/
58545857
static Plan *
58555858
prepare_sort_from_pathkeys(Plan *lefttree, List *pathkeys,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy