Reindex or Analyze Tables on PostgreSQL after import
-
09-03-2021 - |
Question
I used PostgreSQL 9.5 on a server and I ended up migrating the data to a new server using PosgreSQL 12.
Should I perform a REINDEX
for all tables or just ANALYZE
for all tables?
Solution
If you use pg_dump/pg_restore, then all indexes are created during pg_restore (after the data was loaded), so there is no reason to run reindex
.
pg_restore however, does not import any statistics, so running analyze
directly after running pg_restore
is a very good idea.
Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange