Skip to main content

How do you handle massive table bloat in mission-critical tables without downtime?

Expert PostgreSQL
Quick Answer Handle massive table bloat without downtime: pg_repack rebuilds the table online. CREATE new table, migrate data in batches via background job, swap with original using a brief exclusive lock. Partition the table and detach old bloated partitions. VACUUM FULL on a replica, then promote. Partition pruning prevents scanning bloated old partitions. Prevention: tune autovacuum aggressively for high-write tables.

Answer

Use pg_repack to rebuild tables and indexes online with shadow copies. Alternatively rebuild tables on replicas via logical replication and fail over. VACUUM FULL is avoided due to locking.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice