pgsql: Fix overoptimistic assumptions in column width estimation for su

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix overoptimistic assumptions in column width estimation for su
Дата
Msg-id E1QvyIJ-0001mk-Ne@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix overoptimistic assumptions in column width estimation for subqueries.

set_append_rel_pathlist supposed that, while computing per-column width
estimates for the appendrel, it could ignore child rels for which the
translated reltargetlist entry wasn't a Var.  This gave rise to completely
silly estimates in some common cases, such as constant outputs from some or
all of the arms of a UNION ALL.  Instead, fall back on get_typavgwidth to
estimate from the value's datatype; which might be a poor estimate but at
least it's not completely wacko.

That problem was exposed by an Assert in set_subquery_size_estimates, which
unfortunately was still overoptimistic even with that fix, since we don't
compute attr_widths estimates for appendrels that are entirely excluded by
constraints.  So remove the Assert; we'll just fall back on get_typavgwidth
in such cases.

Also, since set_subquery_size_estimates calls set_baserel_size_estimates
which calls set_rel_width, there's no need for set_subquery_size_estimates
to call get_typavgwidth; set_rel_width will handle it for us if we just
leave the estimate set to zero.  Remove the unnecessary code.

Per report from Erik Rijkers and subsequent investigation.

Branch
------
REL9_1_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/48f545a3aef461a635b975443a99dd268269590a

Modified Files
--------------
src/backend/optimizer/path/allpaths.c |   45 ++++++++++++++++++++++++---------
src/backend/optimizer/path/costsize.c |   21 ++++++++-------
2 files changed, 44 insertions(+), 22 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix overoptimistic assumptions in column width estimation for su
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Make CREATE EXTENSION check schema creation permissions.