pgsql: Create infrastructure for moving-aggregate optimization. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Create infrastructure for moving-aggregate optimization.
Date
Msg-id E1WZ0Tg-0002x9-Im@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Create infrastructure for moving-aggregate optimization.

Until now, when executing an aggregate function as a window function
within a window with moving frame start (that is, any frame start mode
except UNBOUNDED PRECEDING), we had to recalculate the aggregate from
scratch each time the frame head moved.  This patch allows an aggregate
definition to include an alternate "moving aggregate" implementation
that includes an inverse transition function for removing rows from
the aggregate's running state.  As long as this can be done successfully,
runtime is proportional to the total number of input rows, rather than
to the number of input rows times the average frame length.

This commit includes the core infrastructure, documentation, and regression
tests using user-defined aggregates.  Follow-on commits will update some
of the built-in aggregates to use this feature.

David Rowley and Florian Pflug, reviewed by Dean Rasheed; additional
hacking by me

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/a9d9acbf219b9e96585779cd5f99d674d4ccba74

Modified Files
--------------
doc/src/sgml/catalogs.sgml                     |   43 ++
doc/src/sgml/ref/create_aggregate.sgml         |  153 +++++-
doc/src/sgml/xaggr.sgml                        |  197 +++++++-
src/backend/catalog/pg_aggregate.c             |  241 ++++++++-
src/backend/commands/aggregatecmds.c           |  101 +++-
src/backend/executor/nodeAgg.c                 |   13 +-
src/backend/executor/nodeWindowAgg.c           |  639 ++++++++++++++++++++----
src/backend/optimizer/util/clauses.c           |    6 +-
src/backend/parser/parse_agg.c                 |   32 +-
src/bin/pg_dump/pg_dump.c                      |   68 +++
src/include/catalog/catversion.h               |    2 +-
src/include/catalog/pg_aggregate.h             |  302 +++++------
src/include/nodes/execnodes.h                  |    3 +-
src/include/parser/parse_agg.h                 |    2 +
src/test/regress/expected/create_aggregate.out |   35 ++
src/test/regress/expected/opr_sanity.out       |  122 ++++-
src/test/regress/expected/window.out           |  223 +++++++++
src/test/regress/sql/create_aggregate.sql      |   41 ++
src/test/regress/sql/opr_sanity.sql            |  103 +++-
src/test/regress/sql/window.sql                |  192 +++++++
20 files changed, 2228 insertions(+), 290 deletions(-)


pgsql-committers by date:

Previous
From: Bruce Momjian
Date:
Subject: pgsql: docs: psql '--' comments are not passed to the server
Next
From: Tom Lane
Date:
Subject: pgsql: Provide moving-aggregate support for a bunch of numerical aggreg