2.4. 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 the autovacuum daemon or manually on the whole database, statistics from foreign partitions is 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 statistics is fetched from foreign servers.
Note
Database-wide ANALYZE
relies on statistics being available on remote shards. But statistics on remote shards may be missing, and it is not enough to just broadcast ANALYZE
for cluster-wide update of statistics. Instead, shardman.global_analyze() function can be used. It performs gathering of statistics for sharded and global tables.
Database-wide VACUUM
command can be broadcast to perform cluster-wide vacuuming. It can be done when the shardman.broadcast_ddl
configuration parameter is on.
Note
When ANALYZE
is run on a global table, only statistics on corresponding local table is updated. When ANALYZE
is run on a sharded table, statistics on local partitions is updated, statistics for foreign partitions is transferred from remote nodes, if remote nodes have it. When ANALYZE
is run on a foreign table directly and remote node doesn't have any statistics for the corresponding local table, local table is analyzed remotely. Then statistics is transferred from the remote node.
When VACUUM
is run on a sharded or global table, the statement is broadcast. For a sharded table, it is efficiently run on all table partitions.