CREATE INDEX: do not update stats during binary upgrade.
authorJeff Davis <jdavis@postgresql.org>
Wed, 3 Apr 2024 23:12:45 +0000 (16:12 -0700)
committerJeff Davis <jdavis@postgresql.org>
Wed, 3 Apr 2024 23:12:45 +0000 (16:12 -0700)
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

src/backend/catalog/index.c

index b6a7c60e230fc9afe18aa669a1e1351b4a1e0449..9b7ef71d6fe3377f7b2d09015c36e41f10168a08 100644 (file)
@@ -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;