Reindex or backup/restore to optimize database? Do indexes rebuild while restoring db from backup?
1 Answer
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.
VACUUM FULL(-foption) 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