pgsql: Improve cost estimation for aggregates and window functions.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Improve cost estimation for aggregates and window functions.
Date: 2011-04-24 20:55:42
Message-ID: E1QE6LG-0000Kq-Nu@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2011-04-24 22:26:34 pgsql: Normalize whitespace in the arguments of <indexterm>
Previous Message Hiroshi Saito 2011-04-24 04:43:59 psqlodbc - psqlodbc: Add change history.