When data is deleted from the SQLite database, unused disk space is added to an internal "Free List. This part of space can be reused when you insert data next time. The disk space will not be lost, but will not be returned to the operating system.
If you delete a large amount of data and want to reduce the space occupied by database files, run the VACUUM command. Vacuum
The database will be re-organized from scratch. This will use an empty "Free linked list" in the database, and the database file will be minimal. However, it takes some time to execute vacuum.
(During SQLite development, it takes about half a second every M bytes on Linux.) In addition, the execution process requires up to two times the temporary disk space of the original database file.
/// <Summary> /// execute the compressed database /// </Summary> /// <returns> compress the database </returns> Public static void executezip () {using (sqliteconnection connection = new sqliteconnection (connectionstring) {using (sqlitecommand cmd = new sqlitecommand ("vacuum", connection) {try {connection. open (); cmd. executenonquery ();} catch (system. data. SQLite. sqliteexception e) {connection. close (); log. debug (E. message); // throw new exception (E. message );}}}}