pgsql: Build inherited extended stats on partitioned tables
От | Tomas Vondra |
---|---|
Тема | pgsql: Build inherited extended stats on partitioned tables |
Дата | |
Msg-id | E1n8nm0-000401-3H@gemulon.postgresql.org обсуждение исходный текст |
Список | pgsql-committers |
Build inherited extended stats on partitioned tables Commit 859b3003de disabled building of extended stats for inheritance trees, to prevent updating the same catalog row twice. While that resolved the issue, it also means there are no extended stats for declaratively partitioned tables, because there are no data in the non-leaf relations. That also means declaratively partitioned tables were not affected by the issue 859b3003de addressed, which means this is a regression affecting queries that calculate estimates for the whole inheritance tree as a whole (which includes e.g. GROUP BY queries). But because partitioned tables are empty, we can invert the condition and build statistics only for the case with inheritance, without losing anything. And we can consider them when calculating estimates. It may be necessary to run ANALYZE on partitioned tables, to collect proper statistics. For declarative partitioning there should no prior statistics, and it might take time before autoanalyze is triggered. For tables partitioned by inheritance the statistics may include data from child relations (if built 859b3003de), contradicting the current code. Report and patch by Justin Pryzby, minor fixes and cleanup by me. Backpatch all the way back to PostgreSQL 10, where extended statistics were introduced (same as 859b3003de). Author: Justin Pryzby Reported-by: Justin Pryzby Backpatch-through: 10 Discussion: https://postgr.es/m/20210923212624.GI831%40telsasoft.com Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/d6817032d26becd3c49f11d16efd6012e2139fc4 Modified Files -------------- src/backend/commands/analyze.c | 18 +++++++++++++++++- src/backend/statistics/dependencies.c | 9 ++++++--- src/backend/statistics/extended_stats.c | 9 ++++++--- src/backend/utils/adt/selfuncs.c | 20 ++++++++++++-------- src/test/regress/expected/stats_ext.out | 19 +++++++++++++++++++ src/test/regress/sql/stats_ext.sql | 10 ++++++++++ 6 files changed, 70 insertions(+), 15 deletions(-)
В списке pgsql-committers по дате отправления: