From: Jeff Davis Date: Wed, 3 Apr 2024 23:12:45 +0000 (-0700) Subject: CREATE INDEX: do not update stats during binary upgrade. X-Git-Tag: REL_17_BETA1~421 X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=71b66171d045878cb9267a268a3bf8ce4f11f333;p=postgresql.git CREATE INDEX: do not update stats during binary upgrade. During binary upgrade, indexes are created before the data is moved into place, so it will always be zero. This is not currently a major problem, but will be when we try to preserve statistics during upgrade. Author: Corey Huinker Discussion: https://postgr.es/m/CADkLM=daPdFB8V0tgFxK-dLowFsAEzWRWJHyxij7BG3kBjcouA@mail.gmail.com --- diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index b6a7c60e230..9b7ef71d6fe 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -2874,7 +2874,11 @@ index_update_stats(Relation rel, dirty = true; } - if (reltuples >= 0) + /* + * Avoid updating statistics during binary upgrade, because the indexes + * are created before the data is moved into place. + */ + if (reltuples >= 0 && !IsBinaryUpgrade) { BlockNumber relpages = RelationGetNumberOfBlocks(rel); BlockNumber relallvisible;