CREATE INDEX: don't update table stats if autovacuum=off.
authorJeff Davis <jdavis@postgresql.org>
Fri, 7 Mar 2025 03:36:34 +0000 (19:36 -0800)
committerJeff Davis <jdavis@postgresql.org>
Fri, 7 Mar 2025 03:39:14 +0000 (19:39 -0800)
commitd611f8b1587b8f30caa7c0da99ae5d28e914d54f
tree81e8e261c9988b878fd80e095814e8029d53d246
parent19e57f4f78e4354d9a21c284868373d28bb0d368
CREATE INDEX: don't update table stats if autovacuum=off.

We previously fixed this for binary upgrade in 71b66171d0, but a
similar problem remained when dumping statistics without data.

Fix by not opportunistically updating table stats during CREATE INDEX
when autovacuum is disabled. For stats to be stable at all, the server
needs to be aware that it should not take every opportunity to update
stats. Per discussion, autovacuum=off is a signal that the user
expects stats to be stable; though if necessary, we could create
a more specific mode in the future.

Reported-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://postgr.es/m/CAExHW5vf9D+8-a5_BEX3y=2y_xY9hiCxV1=C+FnxDvfprWvkng@mail.gmail.com
Discussion: https://postgr.es/m/ca81cbf6e6ea2af838df972801ad4da52640a503.camel%40j-davis.com
src/backend/catalog/index.c
src/test/regress/expected/stats_import.out
src/test/regress/sql/stats_import.sql