In PostgreSQL, every row version (tuple) carries a creation transaction ID (XID). As databases age, those XIDs risk wrapping around, potentially corrupting data visibility. Normal VACUUM operations periodically mark very old tuples as frozen so they are skipped in the wraparound calculation. Specifying FREEZE forces VACUUM to treat *all* tuples that are visible to all active transactions as old enough to be frozen, even if they would not yet qualify under the autovacuum_freeze_min_age threshold.Once a tuple is frozen, its XID is replaced with a special FrozenXID constant. Frozen tuples are thereafter immune to wraparound problems, so future VACUUM runs can skip them, reducing maintenance work. However, FREEZE scans the entire table and can generate extra I/O, which is why it is typically used during low-traffic periods or after large data loads.FREEZE can be written in two syntaxes:1. Legacy: VACUUM FREEZE [FULL] [ANALYZE] table_name;2. Parameter style: VACUUM (FREEZE [boolean], FULL, ANALYZE) table_name;Important caveats:- FREEZE still obeys MVCC rules and will not touch tuples that are either not yet visible to every transaction or are still required by any active snapshot.- Although FREEZE reduces future vacuum effort, it does not make further VACUUMs unnecessary; it only exempts already-frozen tuples.- FREEZE has no effect on indexes beyond the usual VACUUM processing.
VACUUM, FULL, ANALYZE, AUTOVACUUM, transaction ID wraparound, pg_class.relfreezeid
PostgreSQL 8.2
VACUUM FREEZE only takes an ACCESS SHARE lock, so normal SELECT, INSERT, UPDATE, and DELETE operations proceed. It blocks operations that need stronger locks such as certain ALTER TABLE commands.
Use it after bulk inserts, before archiving partitions, or when a table's age approaches autovacuum_freeze_max_age to avoid emergency wraparound vacuums.
Yes. You can pair FREEZE with FULL or ANALYZE either in the legacy syntax (VACUUM FULL FREEZE) or the option list syntax (VACUUM (FULL, FREEZE, ANALYZE)).
No. It only exempts the frozen tuples. Routine VACUUM is still required for new or updated rows to reclaim space and maintain visibility maps.