pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@postgresql.org
Subject: pgsql: Share transition state between different aggregates when possibl
Date: Tue, 04 Aug 2015 15:02:29 +0000
Message-ID: <E1ZMdjZ-0006x7-1I@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

Share transition state between different aggregates when possible.

If there are two different aggregates in the query with same inputs, and
the aggregates have the same initial condition and transition function,
only calculate the state value once, and only call the final functions
separately. For example, AVG(x) and SUM(x) aggregates have the same
transition function, which accumulates the sum and number of input tuples.
For a query like "SELECT AVG(x), SUM(x) FROM x", we can therefore
accumulate the state function only once, which gives a nice speedup.

David Rowley, reviewed and edited by me.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/804163bc25e979fcd91b02e58fa2d1c6b587cc65

Modified Files
--------------
src/backend/executor/execQual.c          |   22 +-
src/backend/executor/nodeAgg.c           | 1070 +++++++++++++++++++-----------
src/backend/executor/nodeWindowAgg.c     |   31 +-
src/backend/parser/parse_agg.c           |   75 ++-
src/include/nodes/execnodes.h            |    8 +-
src/include/parser/parse_agg.h           |   14 +-
src/test/regress/expected/aggregates.out |  204 ++++++
src/test/regress/sql/aggregates.sql      |  165 +++++
8 files changed, 1132 insertions(+), 457 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


Message-ID: <E1ZMdjZ-0006x7-1I@gemulon.postgresql.org>
Permalink:  ../E1ZMdjZ-0006x7-1I@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1ZMdjZ-0006x7-1I@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: heikki.linnakangas@iki.fi
  Subject: Re: pgsql: Share transition state between different aggregates when possibl
  In-Reply-To: <E1ZMdjZ-0006x7-1I@gemulon.postgresql.org>
  References: <E1ZMdjZ-0006x7-1I@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox