apps/docs/content/guides/database/extensions/pg_repack.mdx
pg_repack is a Postgres extension to remove bloat from tables and indexes, and optionally restore the physical order of clustered indexes. Unlike CLUSTER and VACUUM FULL, pg_repack runs "online" and does not hold a exclusive locks on the processed tables that could prevent ongoing database operations. pg_repack's efficiency is comparable to using CLUSTER directly.
pg_repack provides the following methods to optimize physical storage:
pg_repack has 2 components, the database extension and a client-side CLI to control it.
pg_repack requires the Postgres superuser role by default. That role is not available to users on the Supabase platform. To avoid that requirement, use the -k or --no-superuser-check flags on every pg_repack CLI command.
The first version of pg_repack with full support for non-superuser repacking is 1.5.2. You can check the version installed on your Supabase instance using
select default_version
from pg_available_extensions
where name = 'pg_repack';
If pg_repack is not present, or the version is < 1.5.2, upgrade to the latest version of Supabase to gain access.
Get started with pg_repack by enabling the extension in the Supabase Dashboard.
<Tabs scrollable size="small" type="underlined" defaultActiveId="dashboard" queryGroup="database-method"
<TabPanel id="dashboard" label="Dashboard">
Select an option from the pg_repack docs to install the client CLI.
All pg_repack commands should include the -k flag to skip the client-side superuser check.
pg_repack -k [OPTION]... [DBNAME]
Perform an online VACUUM FULL on the tables public.foo and public.bar in the database postgres:
pg_repack -k -h db.<PROJECT_REF>.supabase.co -p 5432 -U postgres -d postgres --no-order --table public.foo --table public.bar
See the official pg_repack documentation for the full list of options.