OSDN Git Service

This patch changes int2_avg_accum() and int4_avg_accum() use the nodeAgg
authorNeil Conway <neilc@samurai.com>
Mon, 4 Apr 2005 23:50:27 +0000 (23:50 +0000)
committerNeil Conway <neilc@samurai.com>
Mon, 4 Apr 2005 23:50:27 +0000 (23:50 +0000)
commit51b2f8ba5593558312157720c3d8e1dcfd8744b3
tree64cc061c1831851e6903210fff7253da17895bc5
parent8bbe905a2ed1d25d472b4188cec06c54f82f0890
This patch changes int2_avg_accum() and int4_avg_accum() use the nodeAgg
performance hack Tom introduced recently. This means we can avoid
copying the transition array for each input tuple if these functions
are invoked as aggregate transition functions.

To test the performance improvement, I created a 1 million row table
with a single int4 column. Without the patch, SELECT avg(col) FROM
table took about 4.2 seconds (after the data was cached); with the
patch, it took about 3.2 seconds. Naturally, the performance
improvement for a less trivial query (or a table with wider rows)
would be relatively smaller.
src/backend/utils/adt/numeric.c