]> granicus.if.org Git - postgresql/commit
Allow the built-in ordered-set aggregates to share transition state.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 16 Oct 2017 19:51:23 +0000 (15:51 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 16 Oct 2017 19:51:23 +0000 (15:51 -0400)
commitbe0ebb65f51225223421df6e10eb6e87fc8264d7
tree47f81081e66bb4f8ad984b8f56f9b62d3bacfd51
parentc3dfe0fec01469b8a7de327303cad50ba8ed338a
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
src/backend/executor/nodeAgg.c
src/backend/utils/adt/orderedsetaggs.c
src/include/catalog/catversion.h
src/include/catalog/pg_aggregate.h
src/include/fmgr.h
src/test/regress/expected/aggregates.out
src/test/regress/sql/aggregates.sql