pgsql: Improve relation width estimation for subqueries. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Improve relation width estimation for subqueries.
Date
Msg-id E1PJZVO-0006F7-F1@gemulon.postgresql.org
Whole thread Raw
List 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(-)


pgsql-committers by date:

Previous
From: bloodnok@pgfoundry.org (User Bloodnok)
Date:
Subject: veil - veil: Updates for version 9.1.12 release, to work with Postgres
Next
From: hinoue@pgfoundry.org (User Hinoue)
Date:
Subject: psqlodbc - psqlodbc: Divide SC_returns_rows() macro into several