Sobes.tech
Junior — Middle

Can you explain what VACUUM FULL command means in SQL and how it differs from the regular VACUUM?

sobes.tech AI

Answer from AI

The VACUUM command in SQL (most often in PostgreSQL) is used to clean up the database from "dead" rows that remain after updates or deletions, in order to free space and prevent table bloat.

VACUUM FULL is a more intensive version of the command, which not only cleans but also completely reorganizes the table, compressing it and releasing disk space back to the operating system. However, VACUUM FULL locks the table during execution, which can affect data availability.

Main differences:

  • VACUUM runs quickly and does not lock the table for read/write.
  • VACUUM FULL takes more time, locks the table, and returns disk space.

Use VACUUM FULL when you need to significantly reduce the size of the table on disk, for example, after mass data deletion.