]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Don't build extended statistics on inheritance trees
authorTomas Vondra <tomas.vondra@postgresql.org>
Tue, 30 Jul 2019 17:17:12 +0000 (19:17 +0200)
committerTomas Vondra <tomas.vondra@postgresql.org>
Tue, 30 Jul 2019 17:48:26 +0000 (19:48 +0200)
commit4dbf70b2ff1ee487923394fd9e4fb28bb78839f2
treed13069f5e9eea8bc6c201cfd2b8002d53af6d708
parent0dcb1c6c4874d2d464d426ded208b58b01e52174
Don't build extended statistics on inheritance trees

When performing ANALYZE on inheritance trees, we collect two samples for
each relation - one for the relation alone, and one for the inheritance
subtree (relation and its child relations). And then we build statistics
on each sample, so for each relation we get two sets of statistics.

For regular (per-column) statistics this works fine, because the catalog
includes a flag differentiating statistics built from those two samples.
But we don't have such flag in the extended statistics catalogs, and we
ended up updating the same row twice, triggering this error:

  ERROR:  tuple already updated by self

The simplest solution is to disable extended statistics on inheritance
trees, which is what this commit is doing. In the future we may need to
do something similar to per-column statistics, but that requires adding a
flag to the catalog - and that's not backpatchable. Moreover, the current
selectivity estimation code only works with individual relations, so
building statistics on inheritance trees would be pointless anyway.

Author: Tomas Vondra
Backpatch-to: 10-
Discussion: https://postgr.es/m/20190618231233.GA27470@telsasoft.com
Reported-by: Justin Pryzby
src/backend/commands/analyze.c
src/test/regress/expected/stats_ext.out
src/test/regress/sql/stats_ext.sql