postgres table and index bloat - ghdrako/doc_snipets GitHub Wiki

pgcompacttable

reindex

In PostgreSQL 12, REINDEX gained support for the CONCURRENTLY option. This works similarly to how pg_repack does, but itโ€™s native to PostgreSQL. By being native, it continues to receive improvements in newer versions.

REINDEX (VERBOSE)  INDEX  CONCURRENTLY index_trips_on_driver_id;

Providing a table name as an option to REINDEX performs a reindex for all indexes that are on the specified table.

REINDEX (VERBOSE)  TABLE  CONCURRENTLY trips;