VACUUM Statement
The VACUUM statement only has basic support in DuckDB and is mostly provided for PostgreSQL-compatibility.
Some variants of it, such as when calling for a given column, recompute the distinct statistics (the number of distinct entities) if they have become stale due to updates.
Warning The behavior of
VACUUMis not consistent with PostgreSQL semantics and it is likely going to change in the future.
Examples
No-op:
VACUUM;No-op:
VACUUM ANALYZE;Calling VACUUM on a given table-column pair rebuilds statistics for the table and column:
VACUUM my_table(my_column);Rebuild statistics for the table and column:
VACUUM ANALYZE my_table(my_column);The following operation is not supported:
VACUUM FULL;Not implemented Error:Full vacuum optionVacuum with Indexes
Warning This feature is experimental.
By default, VACUUM skips tables that have ART indexes. The vacuum_rebuild_indexes setting enables vacuum to compact row groups on tables with indexes by rebuilding the indexes afterward. The setting specifies a row count threshold: tables exceeding the threshold are skipped. Set to 0 to disable (the default).
SET vacuum_rebuild_indexes = 1000000;Reclaiming Space
The VACUUM statement does not reclaim space.
For instructions on reclaiming space, refer to the “Reclaiming space” page.