Kevin
Kevin

Reputation: 73

When need to run a REINDEX in postgres


I create index when table is created, then insert data into table.
I think when the data in the table has been indexed, no need to run a REINDEX even if i delete or insert new data.
Is this right? Or each time, i need to run a REINDEX.

If I need to import a large amount of data into an existing indexed table should it be better to run a REINDEX?
When should I run a REINDEX?

Please tell me. Thanks!

Upvotes: 7

Views: 10356

Answers (1)

Laurenz Albe
Laurenz Albe

Reputation: 246578

You never need to run REINDEX to maintain data integrity; all data modifications will update the index.

In normal situations, you never need to REINDEX. In particular, bulk insert will never fragment an index more than it was before.

Indexes get bloated if you delete lots of rows or if you run UPDATEs faster than autovacuum can keep up with. Then you may need to REINDEX them.

Upvotes: 13

Related Questions