From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: expression eval: Reduce number of steps for agg transition invoc
Date: Mon, 24 Feb 2020 23:27:30 +0000
Message-ID: <E1j6N8M-0004UO-9v@gemulon.postgresql.org> (raw)
expression eval: Reduce number of steps for agg transition invocations.
Do so by combining the various steps that are part of aggregate
transition function invocation into one larger step. As some of the
current steps are only necessary for some aggregates, have one variant
of the aggregate transition step for each possible combination.
To avoid further manual copies of code in the different transition
step implementations, move most of the code into helper functions
marked as "always inline".
The benefit of this change is an increase in performance when
aggregating lots of rows. This comes in part due to the reduced number
of indirect jumps due to the reduced number of steps, and in part by
reducing redundant setup code across steps. This mainly benefits
interpreted execution, but the code generated by JIT is also improved
a bit.
As a nice side-effect it also ends up making the code a bit simpler.
A small additional optimization is removing the need to set
aggstate->curaggcontext before calling ExecAggInitGroup, choosing to
instead passign curaggcontext as an argument. It was, in contrast to
other aggregate related functions, only needed to fetch a memory
context to copy the transition value into.
Author: Andres Freund
Discussion:
https://postgr.es/m/20191023163849.sosqbfs5yenocez3@alap3.anarazel.dehttps://postgr.es/m/5c371df7cee903e8cd4c685f90c6c72086d3a2dc.camel@j-davis.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/2742c45080077ed3b08b810bb96341499b86d530
Modified Files
--------------
src/backend/executor/execExpr.c | 105 ++++++------
src/backend/executor/execExprInterp.c | 307 +++++++++++++++++++++-------------
src/backend/executor/nodeAgg.c | 5 +-
src/backend/jit/llvm/llvmjit_expr.c | 229 +++++++++----------------
src/include/executor/execExpr.h | 34 +---
5 files changed, 332 insertions(+), 348 deletions(-)
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: andres@anarazel.de
Subject: Re: pgsql: expression eval: Reduce number of steps for agg transition invoc
In-Reply-To: <E1j6N8M-0004UO-9v@gemulon.postgresql.org>
References: <E1j6N8M-0004UO-9v@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