postgresql/src/include/nodes
David Rowley ed1a88ddac Allow window functions to adjust their frameOptions
WindowFuncs such as row_number() don't care if it's called with ROWS
UNBOUNDED PRECEDING AND CURRENT ROW or with RANGE UNBOUNDED PRECEDING AND
CURRENT ROW.  The latter is less efficient as the RANGE option requires
that the executor check for peer rows, so using the ROW option instead
would cause less overhead.  Because RANGE is part of the default frame
options for WindowClauses, it means WindowAgg is, by default, working much
harder than it needs to for window functions where the ROWS / RANGE option
has no effect on the window function's result.

On a test query from the discussion thread, a performance improvement of
344% was seen by using ROWS instead of RANGE.

Here we add a new support function node type to allow support functions to
be called for window functions so that the most optimal version of the
frame options can be set.  The planner has been adjusted so that the frame
options are changed only if all window functions sharing the same window
clause agree on what the optimized frame options are.

Here we give the ability for row_number(), rank(), dense_rank(),
percent_rank(), cume_dist() and ntile() to alter their WindowClause's
frameOptions.

Reviewed-by: Vik Fearing, Erwin Brandstetter, Zhihong Yu
Discussion: https://postgr.es/m/CAGHENJ7LBBszxS+SkWWFVnBmOT2oVsBhDMB1DFrgerCeYa_DyA@mail.gmail.com
Discussion: https://postgr.es/m/CAApHDvohAKEtTXxq7Pc-ic2dKT8oZfbRKeEJP64M0B6+S88z+A@mail.gmail.com
2022-12-23 12:43:52 +13:00
..
.gitignore Automatically generate node support functions 2022-07-09 08:53:59 +02:00
bitmapset.h Make Bitmapsets be valid Nodes. 2022-11-13 10:22:45 -05:00
execnodes.h Remove new structure member from ResultRelInfo. 2022-12-08 16:15:00 +09:00
extensible.h Harmonize more parameter names in bulk. 2022-09-20 13:09:30 -07:00
lockoptions.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
makefuncs.h Revert SQL/JSON features 2022-09-01 17:07:14 -04:00
memnodes.h Improve performance of and reduce overheads of memory management 2022-08-29 17:15:00 +12:00
meson.build Add copyright notices to meson files 2022-12-20 07:54:39 -05:00
miscnodes.h Create infrastructure for "soft" error reporting. 2022-12-09 09:58:38 -05:00
multibitmapset.h Invent "multibitmapsets", and use them to speed up antijoin detection. 2022-11-16 13:58:44 -05:00
nodeFuncs.h Revise tree-walk APIs to improve spec compliance & silence warnings. 2022-09-20 18:03:22 -04:00
nodes.h Remove gen_node_support.pl's special treatment of EquivalenceClasses. 2022-12-02 15:20:30 -05:00
params.h Harmonize more parameter names in bulk. 2022-09-20 13:09:30 -07:00
parsenodes.h Add grantable MAINTAIN privilege and pg_maintain role. 2022-12-13 17:33:28 -08:00
pathnodes.h Rework query relation permission checking 2022-12-06 16:09:24 +01:00
pg_list.h Doc: update pg_list.h header comments to include XidLists. 2022-12-17 10:31:25 -05:00
plannodes.h Rework query relation permission checking 2022-12-06 16:09:24 +01:00
primnodes.h Replace SQLValueFunction by COERCE_SQL_SYNTAX 2022-11-21 18:31:59 +09:00
print.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
readfuncs.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
replnodes.h Fix limitations on what SQL commands can be issued to a walsender. 2022-01-24 15:33:38 -05:00
subscripting.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
supportnodes.h Allow window functions to adjust their frameOptions 2022-12-23 12:43:52 +13:00
tidbitmap.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
value.h Harmonize more parameter names in bulk. 2022-09-20 13:09:30 -07:00