pgsql: Save a few cycles in advance_transition_function().

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Save a few cycles in advance_transition_function().
Date: 2014-01-08 18:59:20
Message-ID: E1W0yLY-00054T-7s@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Save a few cycles in advance_transition_function().

Keep a pre-initialized FunctionCallInfoData in AggStatePerAggData, and
re-use that at each row instead of doing InitFunctionCallInfoData each
time. This saves only half a dozen assignments and maybe some stack
manipulation, and yet that seems to be good for a percent or two of the
overall query run time for simple aggregates such as count(*). The cost
is that the FunctionCallInfoData (which is about a kilobyte, on 64-bit
machines) stays allocated for the duration of the query instead of being
short-lived stack data. But we're already paying an equivalent space cost
for each regular FuncExpr or OpExpr node, so I don't feel bad about paying
it for aggregate functions. The code seems a little cleaner this way too,
since the number of things passed to advance_transition_function decreases.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/e6336b8b5772b9856d65ef967e0b9f748f0f7b0b

Modified Files
--------------
src/backend/executor/nodeAgg.c | 65 +++++++++++++++++++++++-----------------
1 file changed, 38 insertions(+), 27 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2014-01-08 19:34:35 pgsql: Avoid extra AggCheckCallContext() checks in ordered-set aggregat
Previous Message Heikki Linnakangas 2014-01-08 14:56:39 pgsql: Fix bug in determining when recovery has reached consistency.