Parallel Vacuum

Available from PostgreSQL 13.

Use multiple cores to run VACUUM.

When PostgreSQL runs vacuum, it marks spaces in a table available for re-use. It does not actually return the space to the operating systems, so PostgreSQL can use multiple CPUs to process indexes.

Parallel VACUUM does not need exclusive lock. So you can still do SELECT, INSERT, UPDATE, and DELETE.

So if you have a table that has many indexes, PostgreSQL can vacuum your indexes concurrently.

You can manually specify number of cores to VACUUM:

VVACUUM (ANALYZE, VERBOSE, PARALLEL 8) users;

You can use up to 8 cores max_parallel_maintenance_workers. An index will could be parallel vacuum candidate if it is bigger than min_parallel_index_scan_size.

1 core works on 1 index.

Parallel workers only launched when there are 2+ indexes in the table.

You also need to tune shared_buffers and maintenance_work_mem.

You cant use PARALLEL option with VACUUM FULL:

=# VACUUM (FULL, PARALLEL 8) users;
ERROR:  VACUUM FULL cannot be performed in parallel