Order active window clauses for greater reuse of Sort nodes.
Andrew Gierth <rhodiumtoad@postgresql.org>
Order active window clauses for greater reuse of Sort nodes. By sorting the active window list lexicographically by the sort clause list but putting longer clauses before shorter prefixes, we generate more chances to elide Sort nodes when building the path. Author: Daniel Gustafsson (with some editorialization by me) Reviewed-by: Alexander Kuzmenkov, Masahiko Sawada, Tom Lane Discussion: https://postgr.es/m/124A7F69-84CD-435B-BA0E-2695BE21E5C2%40yesql.se
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/nodes/list.c | modified | +5 −2 |
| src/backend/optimizer/plan/planner.c | modified | +109 −45 |
| src/test/regress/expected/window.out | modified | +47 −13 |
| src/test/regress/sql/window.sql | modified | +16 −0 |
Discussion
- Avoid extra Sort nodes between WindowAggs when sorting can be reused 22 messages · 2018-05-30 → 2018-09-14