4.3. Analyzing and vacuuming

Shardman databases require periodic maintenance known as vacuuming. For many installations, it is sufficient to let vacuuming be performed by the autovacuum daemon. As in PostgreSQL installation, autovacuum daemon will automatically issue ANALYZE commands whenever the content of a table has changed sufficiently. When ANALYZE is run by autovacuum daemon or manually on the whole database, statistics from foreign partitions are transferred from remote nodes.

Rebalance process can move or copy data between cluster nodes. After this operation all transferred objects are automatically analyzed. As usual, local statistics is gathered, and remote is fetched from foreign servers.

Note

Database-wide ANALYZE relies on statistics being available on remote shards. This is not always true and it is not enough to just broadcast ANALYZE for cluster-wide update of statistics. Instead shardman.global_analyze() function can be used. It gathers statistics for sharded and global tables cluster-wide.

Database-wide VACUUM command can be broadcasted to perform cluster-wide vacuuming. It can be done when shardman.broadcast_ddl configuration parameter is on.

Note

When ANALYZE is run on a sharded or a global table, only statistics on local partitions is updated. When ANALYZE is run on a foreign table directly, it tries to acquire sample rows, and currently this leads to fetching all table data.

When VACUUM is run on a sharded or global table, the statement is broadcasted. For sharded table it is efficiently run on all table partitions.