Indexes can become a problem in many database applications that involve a high proportion of inserts/deletes. Just as tables can become bloated, so do indexes.
In the last recipe we saw that non-HOT updates can cause bloated indexes. Non-primary key indexes are also prone to some bloat from normal inserts, as is common in most relational databases.
Autovacuum does not detect bloated indexes, nor does it do anything to rebuild indexes. So we need to look at ways to maintain indexes.
PostgreSQL supports commands that will rebuild indexes for you. The client utility reindexdb allows you to execute the
REINDEX command in a convenient way from the operating system:
This executes the SQL
REINDEX command on every ...