pgsql: Improve performance of numeric sum(), avg(), stddev(), variance(

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Improve performance of numeric sum(), avg(), stddev(), variance(
Дата
Msg-id E1VhpZd-0003le-6z@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Improve performance of numeric sum(), avg(), stddev(), variance(), etc.

This patch improves performance of most built-in aggregates that formerly
used a NUMERIC or NUMERIC array as their transition type; this includes
not only aggregates on numeric inputs, but some aggregates on integer
inputs where overflow of an int8 value is a possibility.  The code now
uses a special-purpose data structure to avoid array construction and
deconstruction overhead, as well as packing and unpacking overhead for
numeric values.

These aggregates' transition type is now declared as INTERNAL, since
it doesn't correspond to any SQL data type.  To keep the planner from
thinking that that means a lot of storage will be used, we make use
of the just-added pg_aggregate.aggtransspace feature.  The space estimate
is set to 128 bytes, which is at least in the right ballpark.

Hadi Moshayedi, reviewed by Pavel Stehule and Tomas Vondra

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/69c8fbac201652282e18b0e2e301d4ada991fbde

Modified Files
--------------
src/backend/utils/adt/numeric.c          |  392 +++++++++++++++++++-----------
src/include/catalog/catversion.h         |    2 +-
src/include/catalog/pg_aggregate.h       |   56 ++---
src/include/catalog/pg_proc.h            |   24 +-
src/include/utils/builtins.h             |    1 +
src/test/regress/expected/aggregates.out |   61 +++++
src/test/regress/sql/aggregates.sql      |   12 +
7 files changed, 362 insertions(+), 186 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Allow aggregates to provide estimates of their transition state
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Add make_date() and make_time() functions.