Issue:
- SQLite database file size keep increasing.
- SQLite database file size not reduced after deleted tables or rows.
Reason:
- In SQLite, when an object (table, index, or trigger) is dropped from the database, it leaves behind empty space. This makes the database file larger than it needs to be, but can speed up INSERT operations. Over time, INSERT and DELETE operations can leave the database file structure fragmented, which slows down disk access to the database contents.
Solution:
- Use VACUUM command rebuilds the entire database; or
- enable auto vacuum in the database, use command pragma auto_vacuum.