In the previous recipe, we saw how pg_repack can be installed as an extension. pg_repack can be used to perform an online VACUUM FULL of a table. This feature is useful in a production environment where downtime is unacceptable. In this recipe, we will discuss how pg_repack can be used to rebuild a table online and look at the steps for using parallelism to finish the rebuild faster.
Getting ready
To use pg_repack, this extension must be installed and created in the database to which the table belongs:
$ psql -d percdb -c "CREATE EXTENSION pg_repack"
The table being rebuilt must have a primary key or a unique index on a NOT NULL column.
It is always recommended to have a valid full backup, as it's helpful for point-in-time recovery, before performing any maintenance on a database server.
How to do it...
The following are the steps required to rebuild a table online using pg_repack:
- Use --dry-run to verify whether the table...