pgsql: Improve relation width estimation for subqueries.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Improve relation width estimation for subqueries.
Date: 2010-11-19 22:32:30
Message-ID: E1PJZVO-0006F7-F1@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Improve relation width estimation for subqueries.

As per the ancient comment for set_rel_width, it really wasn't much good
for relations that aren't plain tables: it would never find any stats and
would always fall back on datatype-based estimates, which are often pretty
silly. Fix that by copying up width estimates from the subquery planning
process.

At some point we might want to do this for CTEs too, but that would be a
significantly more invasive patch because the sub-PlannerInfo is no longer
accessible by the time it's needed. I refrained from doing anything about
that, partly for fear of breaking the unmerged CTE-related patches.

In passing, also generate less bogus width estimates for whole-row Vars.

Per a gripe from Jon Nelson.

Branch
------
master

Details
-------
http://git.postgresql.org/gitweb?p=postgresql.git;a=commitdiff;h=0f61d4dd1b4f95832dcd81c9688dac56fd6b5687

Modified Files
--------------
src/backend/optimizer/path/allpaths.c | 5 +-
src/backend/optimizer/path/costsize.c | 137 +++++++++++++++++++++++++++++++--
src/backend/optimizer/plan/planner.c | 2 +-
src/backend/optimizer/util/plancat.c | 22 ++++--
src/include/optimizer/cost.h | 2 +
src/include/optimizer/plancat.h | 2 +-
6 files changed, 150 insertions(+), 20 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message User Hinoue 2010-11-20 01:47:19 psqlodbc - psqlodbc: Divide SC_returns_rows() macro into several
Previous Message User Bloodnok 2010-11-19 18:08:17 veil - veil: Updates for version 9.1.12 release, to work with Postgres