pg_repack is a PostgreSQL extension that allows you to efficiently reorganize a table to get rid of any excess that it has accumulated. Note that reorganizing a table may take some time, but pg_repack tries to minimize the locks required so that online operations continue.

To use the pg_repack extension:

  1. Run the following command as avnadmin:

    CREATE EXTENSION pg_repack;

  2. Run the command-line tool that comes with the extension on your own machine.
    The command to reorganize a single table looks like the following:

    pg_repack -d connstr --no-superuser-check -t tablename

    This reorganizes the tablename table.

Learn how Aiven simplifies PostgreSQL:

Did this answer your question?