What does it mean to vacuum a database? What does it mean to vacuum a database? database database

What does it mean to vacuum a database?


Databases that use MVCC to isolate transactions from each other need to periodically scan the tables to delete outdated copies of rows. In MVCC, when a row is updated or deleted, it cannot be immediately recycled because there might be active transactions that can still see the old version of the row. Instead of checking if that is the case, which could be quite costly, old rows are assumed to stay relevant. The process of reclaiming the space is deferred until the table is vacuumed which, depending on the database, can be initiated automatically or explicitly.


It is specifically referring to SQL lite vacuum command. http://www.sqlite.org/lang_vacuum.html

It is removing space left over from DELETE statements.


'vacuumdb' is in MySQL, sqlite and PostgreSQL. In Postgres, vacuumdb identifies space that's occupied by deleted rows and catalogues it for future use. 'vacuum full' does a more comprehensive examination and moves records into the newly created space.