pg-repack-runbook

Rebuild bloated PostgreSQL tables online with pg_repack.

Updated Apr 22, 2026
One-click install
npx skills add https://github.com/Mercurium-Analytics/pg-search-vector --skill pg-repack-runbook
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pg-repack-runbook
Source: https://github.com/Mercurium-Analytics/pg-search-vector/tree/main/skills/pg-repack-runbook
Command: npx skills add https://github.com/Mercurium-Analytics/pg-search-vector --skill pg-repack-runbook

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Reclaims disk space on bloated PostgreSQL tables by online rebuilding with pg_repack, reducing downtime and maintenance windows.

Core Features & Use Cases

  • Repack bloated tables online with minimal downtime using a shadow table approach.
  • Repack indexes concurrently to reduce lock times during maintenance.
  • Follow a safe operational checklist: prerequisites include superuser access and a primary key or unique not-null index on target tables; monitor and rehearse in maintenance windows.

Quick Start

Install and run the recommended pg_repack runbook steps to begin repacking a bloated table or index.

Frequently Asked Questions about pg-repack-runbook

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I remove PostgreSQL table bloat without downtime?

You can remove PostgreSQL table bloat without downtime by using pg_repack to online rebuild bloated tables with a shadow table approach, minimizing lock times during maintenance.

What is the difference between pg_repack and vacuum full for bloat removal?

Vacuum full locks the table exclusively during bloat removal, whereas pg_repack uses a shadow table approach to rebuild tables online, requiring only minimal locks and reducing downtime.

Do I need a primary key to repack a bloated PostgreSQL table?

Yes, you need a primary key or a unique not-null index on the target table to repack it online, along with superuser privileges to execute the pg_repack operations.

How do I rebuild indexes concurrently in PostgreSQL to reduce lock times?

You can rebuild indexes concurrently in PostgreSQL by using pg_repack to repack indexes, which reduces lock times and minimizes disruption during maintenance windows.

Can I run pg_repack on production PostgreSQL deployments?

Yes, pg_repack is designed for production PostgreSQL deployments needing online maintenance of bloat, allowing safe table and index reorganization with minimal downtime when prerequisites are met.

When should I not use pg_repack for online table reorganization?

You should not use pg_repack when you lack superuser privileges or when the target table lacks a primary key or unique not-null index, as these are required prerequisites for the repack process.