pgsql: Allow the built-in ordered-set aggregates to share transition st

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Allow the built-in ordered-set aggregates to share transition st
Date: 2017-10-16 19:51:28
Message-ID: E1e4BQ8-0003Xp-Rl@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Allow the built-in ordered-set aggregates to share transition state.

The built-in OSAs all share the same transition function, so they can
share transition state as long as the final functions cooperate to not
do the sort step more than once. To avoid running the tuplesort object
in randomAccess mode unnecessarily, add a bit of infrastructure to
nodeAgg.c to let the aggregate functions find out whether the transition
state is actually being shared or not.

This doesn't work for the hypothetical aggregates, since those inject
a hypothetical row that isn't traceable to the shared input state.
So they remain marked aggfinalmodify = 'w'.

Discussion: https://postgr.es/m/CAB4ELO5RZhOamuT9Xsf72ozbenDLLXZKSk07FiSVsuJNZB861A@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/be0ebb65f51225223421df6e10eb6e87fc8264d7

Modified Files
--------------
src/backend/executor/nodeAgg.c | 52 +++++++++++-
src/backend/utils/adt/orderedsetaggs.c | 133 +++++++++++++++++--------------
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_aggregate.h | 14 ++--
src/include/fmgr.h | 1 +
src/test/regress/expected/aggregates.out | 12 ++-
src/test/regress/sql/aggregates.sql | 8 +-
7 files changed, 149 insertions(+), 73 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2017-10-16 20:02:59 pgsql: Treat aggregate direct arguments as per-agg data not per-trans d
Previous Message Tom Lane 2017-10-16 19:24:49 pgsql: Repair breakage of aggregate FILTER option.