pgsql: Extract column statistics from CTE references, if possible.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Extract column statistics from CTE references, if possible.
Дата
Msg-id E1r44dt-005vfA-HI@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Extract column statistics from CTE references, if possible.

examine_simple_variable() left this as an unimplemented case years
ago, with the result that plans for queries involving un-flattened
CTEs might be much stupider than necessary.  It's not hard to extend
the existing logic for RTE_SUBQUERY cases to also be able to drill
down into CTEs, so let's do that.

There was some discussion of whether this patch breaks the idea
of a MATERIALIZED CTE being an optimization fence.  We concluded
it's okay, because we already allow the outer planner level to
see the estimated width and rowcount of the CTE result, and
letting it see column statistics too seems fairly equivalent.
Basically, what we expect of the optimization fence is that the
outer query should not affect the plan chosen for the CTE query.
Once that plan is chosen, it's okay for the outer planner level
to make use of whatever information we have about it.

Jian Guo and Tom Lane, per complaint from Hans Buschmann

Discussion: https://postgr.es/m/4504e67078d648cdac3651b2960da6e7@nidsa.net

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/f7816aec23eed1dc1da5f9a53cb6507d30b7f0a2

Modified Files
--------------
src/backend/utils/adt/selfuncs.c   | 134 +++++++++++++++++++++++++++----------
src/test/regress/expected/with.out |  18 +++++
src/test/regress/sql/with.sql      |   7 ++
3 files changed, 124 insertions(+), 35 deletions(-)


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

Предыдущее
От: Andres Freund
Дата:
Сообщение: pgsql: meson: Change default of 'selinux' feature option to auto
Следующее
От: Tom Lane
Дата:
Сообщение: Re: pgsql: docs: Document --with-selinux/-Dselinux options centrally