# pg_repack — Postgres extension

> Remove table and index bloat without long locks.

Source: https://scribase.com/extensions/pg_repack

Category: Performance. Version: 1.5.3. Optional, enabled per project.

## About

pg_repack rebuilds a bloated table or index online, holding an exclusive lock only briefly at the start and end, where VACUUM FULL locks the table for the whole rebuild.

## Enable it

```sql
create extension if not exists pg_repack with schema extensions;
```

## Example

```sql
create extension if not exists pg_repack;

-- then, from a machine with the pg_repack client:
-- pg_repack --table=public.events --dbname="$DATABASE_URL"
```

## Notes

- The rebuild is driven by the pg_repack command-line client over a direct Postgres connection. Direct connections from the internet are not open on hosted projects yet, so today the extension can be turned on but not driven from outside.

Upstream: https://github.com/reorg/pg_repack