Compacting a SQLite3 DB file

| Posted: - Last updated:
| Tagged general
| ~100wrds (~1min)

If you have a lot of mutations in your SQLite3 database the file size of the db file will increase a lot over time.

This can be annoying, so you’ll need to clean up old indices and other cruft that’s making your db heavy.

The solution is über-easy:

$ sqlite3 mystuff.db
SQLite version
sqlite> VACUUM;
sqlite> .quit

Note that you need to use capitals here. This will clean your db file and reduce its file size dramatically (depending on the amount of cruft you have, of course).

My site is free of ads and trackers. I record privacy-respecting usage statistics with Fathom.

Was this post helpful to you? Why not ☕ Buy me a coffee or use Brave Browser to send a tip.