summaryrefslogtreecommitdiff
path: root/src/backend/commands/analyze.c
diff options
context:
space:
mode:
authorTomas Vondra <tomas.vondra@postgresql.org>2019-07-30 19:17:12 +0200
committerTomas Vondra <tomas.vondra@postgresql.org>2019-07-30 19:48:39 +0200
commit859b3003de87645b62ee07ef245d6c1f1cd0cedb (patch)
tree9349f0a8ea4c2cb3b2fa2c38e14bc8b7bbcc901d /src/backend/commands/analyze.c
parentaf41ab50fdc592608a12912def17f4628ea52e70 (diff)
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
Diffstat (limited to 'src/backend/commands/analyze.c')
-rw-r--r--src/backend/commands/analyze.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
index 90b2bb1fea4..37b77e28cb9 100644
--- a/src/backend/commands/analyze.c
+++ b/src/backend/commands/analyze.c
@@ -589,9 +589,15 @@ do_analyze_rel(Relation onerel, int options, VacuumParams *params,
thisdata->attr_cnt, thisdata->vacattrstats);
}
- /* Build extended statistics (if there are any). */
- BuildRelationExtStatistics(onerel, totalrows, numrows, rows, attr_cnt,
- vacattrstats);
+ /*
+ * Build extended statistics (if there are any).
+ *
+ * For now we only build extended statistics on individual relations,
+ * not for relations representing inheritance trees.
+ */
+ if (!inh)
+ BuildRelationExtStatistics(onerel, totalrows, numrows, rows,
+ attr_cnt, vacattrstats);
}
/*