mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
CREATE INDEX: do update index stats if autovacuum=off.
This fixes a thinko from commit d611f8b15
. 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
This commit is contained in:
@ -2847,20 +2847,20 @@ index_update_stats(Relation rel,
|
|||||||
* statistics, as the table statistics may be restored before the index is
|
* statistics, as the table statistics may be restored before the index is
|
||||||
* created, and we want to preserve the restored table statistics.
|
* created, and we want to preserve the restored table statistics.
|
||||||
*/
|
*/
|
||||||
if (AutoVacuumingActive())
|
|
||||||
{
|
|
||||||
if (rel->rd_rel->relkind == RELKIND_RELATION ||
|
if (rel->rd_rel->relkind == RELKIND_RELATION ||
|
||||||
rel->rd_rel->relkind == RELKIND_TOASTVALUE ||
|
rel->rd_rel->relkind == RELKIND_TOASTVALUE ||
|
||||||
rel->rd_rel->relkind == RELKIND_MATVIEW)
|
rel->rd_rel->relkind == RELKIND_MATVIEW)
|
||||||
|
{
|
||||||
|
if (AutoVacuumingActive())
|
||||||
{
|
{
|
||||||
StdRdOptions *options = (StdRdOptions *) rel->rd_options;
|
StdRdOptions *options = (StdRdOptions *) rel->rd_options;
|
||||||
|
|
||||||
if (options != NULL && !options->autovacuum.enabled)
|
if (options != NULL && !options->autovacuum.enabled)
|
||||||
update_stats = false;
|
update_stats = false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
update_stats = false;
|
update_stats = false;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Finish I/O and visibility map buffer locks before
|
* Finish I/O and visibility map buffer locks before
|
||||||
|
Reference in New Issue
Block a user