pgsql: Speed up SUM calculation in numeric aggregates.

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Speed up SUM calculation in numeric aggregates.
Date: 2016-09-02 08:52:10
Message-ID: E1bfkCo-0007lJ-3k@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Speed up SUM calculation in numeric aggregates.

This introduces a numeric sum accumulator, which performs better than
repeatedly calling add_var(). The performance comes from using wider digits
and delaying carry propagation, tallying positive and negative values
separately, and avoiding a round of palloc/pfree on every value. This
speeds up SUM(), as well as other standard aggregates like AVG() and
STDDEV() that also calculate a sum internally.

Reviewed-by: Andrey Borodin
Discussion: <c0545351-a467-5b76-6d46-4840d1ea8aa4(at)iki(dot)fi>

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/9cca11c915e458323d0e746c68203f2c11da0302

Modified Files
--------------
src/backend/utils/adt/numeric.c | 601 ++++++++++++++++++++++++++++------
src/test/regress/expected/numeric.out | 16 +
src/test/regress/sql/numeric.sql | 8 +
3 files changed, 522 insertions(+), 103 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2016-09-02 10:52:31 pgsql: Move code shared between libpq and backend from backend/libpq/ t
Previous Message Heikki Linnakangas 2016-09-02 05:39:53 pgsql: Support multiple iterators in the Red-Black Tree implementation.