Optimizing Disk Usage in SQLite with the VACUUM Command

The SQLite VACUUM command is essential to run after modifying your SQLite database, especially after dropping data.

A SQLite database will still take up the same amount of space even after you drop or delete data from it unless you run the VACUUM command.

To run the command, all you have to do is run VACUUM; in the query tab. If you have dropped a lot of data from your database, you should notice that your database takes up less storage.

The VACUUM command works by rebuilding your database, and then deprecates the original. So be cognizant of how much space you have on your machine. For example, if your database is 10 GB database and you removed 4GB of data, during the VACUUM process, you’ll take up a total of 16GB of space (10GB of the original + 6GB of the new database). However, once the process is finished, you’ll only be left with the database that takes up 6GB.


Posted

in

by

Tags: