From: Tomas Vondra <tomas.vondra@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Ignore extended statistics for inheritance trees
Date: Sat, 15 Jan 2022 02:20:18 +0000
Message-ID: <E1n8Yfy-0006Cx-WB@gemulon.postgresql.org> (raw)
Ignore extended statistics for inheritance trees
Since commit 859b3003de we only build extended statistics for individual
relations, ignoring the child relations. This resolved the issue with
updating catalog tuple twice, but we still tried to use the statistics
when calculating estimates for the whole inheritance tree. When the
relations contain very distinct data, it may produce bogus estimates.
This is roughly the same issue 427c6b5b9 addressed ~15 years ago, and we
fix it the same way - by ignoring extended statistics when calculating
estimates for the inheritance tree as a whole. We still consider
extended statistics when calculating estimates for individual child
relations, of course.
This may result in plan changes due to different estimates, but if the
old statistics were not describing the inheritance tree particularly
well it's quite likely the new plans is actually better.
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_10_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/ff0e7c7e840122419054d72a7884fa17ce1a4ab9
Modified Files
--------------
src/backend/statistics/dependencies.c | 9 +++++
src/backend/statistics/extended_stats.c | 1 +
src/backend/utils/adt/selfuncs.c | 8 ++++
src/test/regress/expected/stats_ext.out | 65 +++++++++++++++++++++++++++++++++
src/test/regress/sql/stats_ext.sql | 47 ++++++++++++++++++++++++
5 files changed, 130 insertions(+)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tomas.vondra@postgresql.org
Subject: Re: pgsql: Ignore extended statistics for inheritance trees
In-Reply-To: <E1n8Yfy-0006Cx-WB@gemulon.postgresql.org>
References: <E1n8Yfy-0006Cx-WB@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox