Clean the main database file
VACUUM
The VACUUM command is a QDB extension modeled after a similar command found in PostgreSQL.
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 insertions. In time, insertions and deletions can leave the database file structure fragmented, which slows down disk access to the database contents.
The VACUUM command cleans the main database by copying its contents to a temporary database file and reloading the original database file from the copy. This eliminates free pages, aligns table data to be contiguous, and otherwise cleans up the database file structure.
This command fails if there is an active transaction and has no effect on an in-memory database.
qdb_statement(&db, "PRAGMA auto_vacuum = 1;"); // on qdb_statement(&db, "PRAGMA auto_vacuum = 0;"); // off