Do I need to reindex after vacuum full on Postgres 9.4

19,443

A REINDEX immediately after a VACUUM FULL is useless because VACUUM FULL itself rebuilds the indexes.

This is mentioned in the 9.4 documentation in Recovering Disk Space :

...to reclaim the excess disk space it occupies, you will need to use VACUUM FULL, or alternatively CLUSTER or one of the table-rewriting variants of ALTER TABLE. These commands rewrite an entire new copy of the table and build new indexes for it.

You are correct that this was not the case before version 9.0, which had VACUUM FULL reimplemented differently.

Up to version 8.4, the reference doc for VACUUM mentioned the need to reindex:

The FULL option does not shrink indexes; a periodic REINDEX is still recommended. In fact, it is often faster to drop all indexes, VACUUM FULL, and recreate the indexes.

But this caveat is now obsolete.

Share:
19,443
Akshar Raaj
Author by

Akshar Raaj

I am a software developer with 6+ years of professional software development experience. I have worked with several funded and successful companies. I have worked with small teams as well as large organizations. Get in touch to talk about it in detail. I have served organizations in various capacities which include Backend developer, Full stack developer, Individual Contributor and Technical Architect. I have taken projects from conception phase to production. I know what it takes to architect a scalable and maintainable product. I love working on challengine problems and finding innovative and simple solutions for them. I frequently blog about my learnings. You can read them at https://www.agiliq.com/authors/#Akshar. My posts have been read over a million times :) I strongly believe that if correct processes and tools are in place, then any company can reach it's goals irrespective of the team size location and timezone of its employees.

Updated on June 03, 2022

Comments

  • Akshar Raaj
    Akshar Raaj almost 2 years

    I am using Postgres 9.4.

    I just ran vacuum full. I read about the differences between vacuum and vacuum full and considered a lot if I should run vacuum or vacuum full. As far as I can say, I required vacuum full and my db size came down from 48 GB to 24 GB.

    Would the old indexes would have become obsolete after vacuum full and do I need to run reindex?

    I ran "vacuum full verbose analyze", so analyze is done along with vacuum full.

    I read at several places that for Postgres > 9.0, I don't need reindex after vacuum full, but I want to be sure that it is the case.