Select a documentation version: <button class="button button-with-icon cloud-select-dropdown__button button-primary" aria-haspopup="true">15.7.0</button>

- [Current (18.4.0)](https://docs.cloud.google.com/alloydb/omni/kubernetes/current/docs/adaptive-autovacuum.md.txt)
- [18.4.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/18.4.0/docs/adaptive-autovacuum.md.txt)
- [18.3.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/18.3.0/docs/adaptive-autovacuum.md.txt)
- [18.1.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/18.1.0/docs/adaptive-autovacuum.md.txt)
- [17.10.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/17.10.0/docs/adaptive-autovacuum.md.txt)
- [17.9.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/17.9.0/docs/adaptive-autovacuum.md.txt)
- [17.7.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/17.7.0/docs/adaptive-autovacuum.md.txt)
- [17.5.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/17.5.0/docs/adaptive-autovacuum.md.txt)
- [16.14.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/16.14.0/docs/adaptive-autovacuum.md.txt)
- [16.13.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/16.13.0/docs/adaptive-autovacuum.md.txt)
- [16.11.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/16.11.0/docs/adaptive-autovacuum.md.txt)
- [16.9.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/16.9.0/docs/adaptive-autovacuum.md.txt)
- [16.8.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/16.8.0/docs/adaptive-autovacuum.md.txt)
- [16.3.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/16.3.0/docs/adaptive-autovacuum.md.txt)
- [15.18.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.18.0/docs/adaptive-autovacuum.md.txt)
- [15.17.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.17.0/docs/adaptive-autovacuum.md.txt)
- [15.15.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.15.0/docs/adaptive-autovacuum.md.txt)
- [15.13.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.13.0/docs/adaptive-autovacuum.md.txt)
- [15.12.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.12.0/docs/adaptive-autovacuum.md.txt)
- [15.7.1](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.7.1/docs/adaptive-autovacuum.md.txt)
- [15.7.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.7.0/docs/adaptive-autovacuum.md.txt)

<br />

This page provides an overview of AlloyDB Omni adaptive autovacuum and describes how to configure it.

<br />

Vacuuming is an important PostgreSQL database maintenance operation. It is used to
reclaim storage space occupied by updated or deleted rows to avoid table or index
bloat. It is also used for freezing transaction IDs to [prevent transaction ID wraparound](https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND) and for updating the table statistics.

For more information about vacuuming, see [Routine vacuuming](https://www.postgresql.org/docs/current/routine-vacuuming.html).

To automate the process of vacuuming and collectively updating the table statistics,
AlloyDB Omni supports adaptive autovacuum. *Adaptive autovacuum* enables
automatic adjustment of vacuum workload when your workload changes, removes dead
tuples, and updates table statistics.

Autovacuum ensures a reliable and consistent application transactional performance
and maintains high availability of the system by preventing transaction ID wraparound.

By default, AlloyDB Omni enables adaptive autovacuum. You can disable
or modify adaptive autovacuum on AlloyDB Omni by [using database flags](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.7.0/docs/adaptive-autovacuum.md.txt#view-cluster).

## Benefits

Adaptive autovacuum offers the following benefits:

- **Automatic adjustment of resources.** AlloyDB Omni automatically adjusts
  resources such as CPU, I/O, number of vacuum processes, and memory for the vacuum
  process based on the real time status of the workload and available resources
  without affecting the system performance.

- **Prevention of transaction ID wraparound.** AlloyDB Omni monitors the
  vacuum progress and transaction ID consumption speed. When necessary,
  AlloyDB Omni throttles its transaction ID consumption by
  vacuuming every table in the database, preventing transaction ID wraparound.

- **Periodic vacuum for tables.** AlloyDB Omni triggers autovacuum
  based on the number of dead tuples and the pages that need to be
  scanned. It removes dead tuples in a timely manner to avoid table or index bloat.

- **Automatic detection of blockers.** AlloyDB Omni automatically detects
  blockers, such as long running transactions, orphan prepared transactions, orphan
  replication slots, and shows warning messages similar to the following in the
  `postgres` log:

  ```sql
  Found a backend process PROCESS_ID with a long running transaction whose transaction
  id age AGE is larger than or equal to the transaction age threshold AGE_THRESHOLD.
  ```

## Configure adaptive autovacuum

By default, adaptive autovacuum is enabled on AlloyDB Omni. You can
disable adaptive autovacuum by
\[setting an instance's database flags\](/alloydb/omni/kubernetes/15.7.0/docs/configure-database-flags)
so that `enable_google_adaptive_autovacuum` is set to `off`.

AlloyDB Omni supports several standard PostgreSQL database flags related
to vacuum and autovacuum, for example, `vacuum_cost_delay` and `autovacuum_vacuum_cost_delay`.
You don't need to set values in any of these flags for adaptive autovacuum to work
because adaptive autovacuum adapts and optimizes its behavior to your real workloads.
If you set values in these flags, then adaptive autovacuum adjusts its behavior
to take your preferences into account.

To see the complete list of supported PostgreSQL database flags related to vacuum
and autovacuum, see [vacuum flags](https://www.postgresql.org/docs/current/runtime-config-resource.html#GUC-VACUUM-COST-DELAY)
and [autovacuum flags](https://www.postgresql.org/docs/current/runtime-config-autovacuum.html).