Postgres: Reindex

 REINDEX TABLE table_name;

Reasons for Reindexing
You might need to reindex a table in the following scenarios: 
  • Index Bloat: Over time, indexes, especially B-tree indexes, can become bloated with empty or nearly-empty pages due to certain data modification patterns (e.g., frequent updates or deletions). Reindexing reclaims this wasted space.
  • Index Corruption: In rare cases of software bugs or hardware failures, an index might become corrupted and no longer contain valid data. Reindexing provides a recovery method.
  • Altered Storage Parameters: If you change an index's storage parameters (like fillfactor), a reindex is needed for the change to take full effect.
  • Failed Concurrent Build: If a CREATE INDEX CONCURRENTLY command fails, it leaves an "invalid" index, which can be rebuilt using REINDEX. 

Comments

Popular posts from this blog

Postgres: Clean up stopped replication slot

PeopleSoft: Clean Up PUM