Skip to main content

What is pg_repack and why is it used?

Senior PostgreSQL
Quick Answer pg_repack reorganizes tables and indexes online without holding an exclusive lock for most of the operation. Rebuilds the table in a new heap, migrates data in batches, tracks changes via triggers, then does a brief swap at the end. Reclaims bloat (like VACUUM FULL) without prolonged downtime. Use on bloated tables that you can't afford to lock. Requires the extension installed in the database.

Answer

pg_repack rebuilds tables and indexes without blocking writes, unlike VACUUM FULL, making it ideal for production cleanup.
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