---
name: "pg_maintenance"
section: "8"
platform: "linux"
package: "postgresql-common"
version: "94lenny1"
release: "Debian 5.0 (Lenny)"
platforms: ["linux"]
url: "https://new.carta.tech/pg_maintenance"
---

# pg\_maintenance(8)

perform maintenance tasks on all clusters

## NAME

pg\_maintenance - perform maintenance tasks on all clusters

## SYNOPSIS

**pg\_maintenance** \[**-f**\|**--full**\] \[**-a**\|**--analyze**\] \[**-v**\|**--verbose**\] \[**--force**\]

## DESCRIPTION

This script performs maintenance actions on all databases in all clusters. In particular, this calls **vacuumdb** on all databases, which frees up unused space and helps to improve database performance (if **--analyze** is specified).

This script is intended to be called regularly in a cronjob.

## OPTIONS

- **-c**, **--cluster** *version/cluster*

  Perform maintenance only on specified cluster. By default, all clusters are handled.

- **-f**, **--full**

  Perform a "full vacuum", which is more effective but takes more time and needs to completely lock tables while working on it.

- **-a**, **--analyze**

  Perform some statistical analyses on the tables which helps to improve database performance. This only needs read access to the tables, thus does not require any locking.

- **-v**, **--verbose**

  Passed to **vacuumdb**, which prints lots of information about the vacuuming and analysis.

- **--force**

  By default a cluster is not processed if autovacuuming is enabled for it. If this option is specified, the cluster is processed regardless of the autovacuum daemon status.

## SEE ALSO

[*vacuumdb*(1)](/vacuumdb/1.md), [*vacuum*(7)](/vacuum/7.md), [*analyze*(7)](/analyze/7.md), [*pg\_ctlcluster*(1)](/pg_ctlcluster/1.md)

## AUTHOR

Martin Pitt \<mpitt@debian.org\>
