Обсуждение: pgsql: Improve relation width estimation for subqueries.

Поиск
Список
Период
Сортировка

pgsql: Improve relation width estimation for subqueries.

От
Tom Lane
Дата:
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(-)