Skip to content

Commit 29d6808

Browse files
committed
CREATE INDEX: do update index stats if autovacuum=off.
This fixes a thinko from commit d611f8b. The intent was to prevent updating the stats of the pre-existing heap if autovacuum is off, but it also disabled updating the stats of the just-created index. There is AFAICS no good reason to do the latter, since there could not be any pre-existing stats to refrain from overwriting, and the zeroed stats that are there to begin with are very unlikely to be useful. Moreover, the change broke our cross-version upgrade tests again. Author: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/1116282.1741374848@sss.pgh.pa.us
1 parent f7c566a commit 29d6808

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/backend/catalog/index.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2847,20 +2847,20 @@ index_update_stats(Relation rel,
28472847
* statistics, as the table statistics may be restored before the index is
28482848
* created, and we want to preserve the restored table statistics.
28492849
*/
2850-
if (AutoVacuumingActive())
2850+
if (rel->rd_rel->relkind == RELKIND_RELATION ||
2851+
rel->rd_rel->relkind == RELKIND_TOASTVALUE ||
2852+
rel->rd_rel->relkind == RELKIND_MATVIEW)
28512853
{
2852-
if (rel->rd_rel->relkind == RELKIND_RELATION ||
2853-
rel->rd_rel->relkind == RELKIND_TOASTVALUE ||
2854-
rel->rd_rel->relkind == RELKIND_MATVIEW)
2854+
if (AutoVacuumingActive())
28552855
{
28562856
StdRdOptions *options = (StdRdOptions *) rel->rd_options;
28572857

28582858
if (options != NULL && !options->autovacuum.enabled)
28592859
update_stats = false;
28602860
}
2861+
else
2862+
update_stats = false;
28612863
}
2862-
else
2863-
update_stats = false;
28642864

28652865
/*
28662866
* Finish I/O and visibility map buffer locks before

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy