VACUUM

Function

VACUUM reclaims storage space occupied by tables or B-tree indexes. In normal database operation, rows that have been deleted or obsoleted by an update are not physically removed from their table; they remain present until a VACUUM is done. Therefore, it is necessary to execute VACUUM periodically, especially on frequently-updated tables.

Precautions

Syntax

Parameter Description

Examples

Delete all tables in the current database.

1
VACUUM;

Reclaim the space of partition P2 of the tpcds.web_returns_p1 table without updating statistics.

1
VACUUM FULL tpcds.web_returns_p1 PARTITION(P2);

Reclaim the tpcds.web_returns_p1 table and update statistics.

1
VACUUM FULL ANALYZE tpcds.web_returns_p1;

Delete all tables in the current database and collect statistics about the query optimizer.

1
VACUUM ANALYZE;

Delete only the reason table.

1
VACUUM (VERBOSE, ANALYZE) reason;