pgsql: Improve cost estimation for aggregates and window functions. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Improve cost estimation for aggregates and window functions.
Date
Msg-id E1QE6LG-0000Kq-Nu@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Improve cost estimation for aggregates and window functions.

The previous coding failed to account properly for the costs of evaluating
the input expressions of aggregates and window functions, as seen in a
recent gripe from Claudio Freire.  (I said at the time that it wasn't
counting these costs at all; but on closer inspection, it was effectively
charging these costs once per output tuple.  That is completely wrong for
aggregates, and not exactly right for window functions either.)

There was also a hard-wired assumption that aggregates and window functions
had procost 1.0, which is now fixed to respect the actual cataloged costs.

The costing of WindowAgg is still pretty bogus, since it doesn't try to
estimate the effects of spilling data to disk, but that seems like a
separate issue.

Branch
------
master

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

Modified Files
--------------
src/backend/optimizer/path/costsize.c   |  116 ++++++++++++++++++++++---------
src/backend/optimizer/plan/createplan.c |   12 ++--
src/backend/optimizer/plan/planagg.c    |    8 ++-
src/backend/optimizer/plan/planner.c    |   39 +++++-----
src/backend/optimizer/prep/prepunion.c  |    4 +-
src/backend/optimizer/util/clauses.c    |   87 +++++++++++++++--------
src/backend/optimizer/util/pathnode.c   |    2 +-
src/include/nodes/relation.h            |   14 ++++
src/include/optimizer/clauses.h         |   10 +--
src/include/optimizer/cost.h            |    4 +-
src/include/optimizer/planmain.h        |    8 +-
11 files changed, 198 insertions(+), 106 deletions(-)


pgsql-committers by date:

Previous
From: h-saito@pgfoundry.org (Hiroshi Saito)
Date:
Subject: psqlodbc - psqlodbc: Add change history.
Next
From: Peter Eisentraut
Date:
Subject: pgsql: Normalize whitespace in the arguments of