diff options
| author | David Rowley | 2023-07-03 00:49:43 +0000 |
|---|---|---|
| committer | David Rowley | 2023-07-03 00:49:43 +0000 |
| commit | c65102006b686ea26194fb539d7a416a089300e0 (patch) | |
| tree | 494a8ac701ea4ac6b158136140fd15e254deadc7 /src/include | |
| parent | 4637a6ac0b40fef701ab850de1be547b927c3013 (diff) | |
Remove redundant PARTITION BY columns from WindowClauses
Here we adjust the query planner to have it remove items from a window
clause's PARTITION BY clause in cases where the pathkey for a column in
the PARTITION BY clause is redundant.
Doing this allows the optimization added in 9d9c02ccd to stop window
aggregation early rather than going into "pass-through" mode to find
tuples belonging to the next partition. Also, when we manage to remove
all PARTITION BY columns, we now no longer needlessly check that the
current tuple belongs to the same partition as the last tuple in
nodeWindowAgg.c. If the pathkey was redundant then all tuples must
contain the same value for the given redundant column, so there's no point
in checking that during execution.
Author: David Rowley
Reviewed-by: Richard Guo
Discussion: https://postgr.es/m/CAApHDvo2ji+hdxrxfXtRtsfSVw3to2o1nCO20qimw0dUGK8hcQ@mail.gmail.com
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/nodes/parsenodes.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index b3bec90e526..88b03cc4725 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -1473,6 +1473,8 @@ typedef struct GroupingSet * if the clause originally came from WINDOW, and is NULL if it originally * was an OVER clause (but note that we collapse out duplicate OVERs). * partitionClause and orderClause are lists of SortGroupClause structs. + * partitionClause is sanitized by the query planner to remove any columns or + * expressions belonging to redundant PathKeys. * If we have RANGE with offset PRECEDING/FOLLOWING, the semantics of that are * specified by startInRangeFunc/inRangeColl/inRangeAsc/inRangeNullsFirst * for the start offset, or endInRangeFunc/inRange* for the end offset. |
