0

Reindex or backup/restore to optimize database? Do indexes rebuild while restoring db from backup?

3
  • 1
    vacuumdb -fzv Commented Apr 3, 2016 at 14:47
  • does it optimize indexes? Commented Apr 3, 2016 at 14:57
  • 2
    VACUUM FULL (-f option) is something like defragmentation. Not sure what you mean by indexes optimization. However it is not the answer but just a proposal. Your question is more appropriate for the dba site Commented Apr 3, 2016 at 15:11

1 Answer 1

1

If practical, a full backup and restore is always better than a simple reindex simply because you also get an extra backup file.

The restore process will (1) create tables, then (2) copy data in and finally (3) create indexes, apply constraints etc.

This is not the same as using CLUSTER of course, which physically re-orders a table based on one of its indexes. In some cases that can be useful.

If you are going to do this though, make sure you have good measurements before and after your "optimization" because many factors affect overall database performance and this may prove pointless.

Sign up to request clarification or add additional context in comments.

1 Comment

IIRC, the statistics are not recreated after a dump+restore. So you still would have to do that. Manually, or by a script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.