Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite no release memory after delete

Tags:

sqlite

Excuse for English

I using SQLite and test it. Insert multi-million row for testing speed. and deletes rows after any insert.

But i know my database size is 33.0 MB..... now database is empty. but size on disk is 33 MB. WHY?

can you help me?

like image 351
Sina Salmani Avatar asked Feb 13 '23 20:02

Sina Salmani


1 Answers

The VACUUM command rebuilds the entire database. There are several reasons an application might do this:

Unless SQLite is running in "auto_vacuum=FULL" mode, when a large amount of data is deleted from the database file it leaves behind empty space, or "free" database pages. This means the database file might be larger than strictly necessary. Running VACUUM to rebuild the database reclaims this space and reduces the size of the database file.

https://www.sqlite.org/lang_vacuum.html

like image 104
MatthewMartin Avatar answered Jun 12 '23 08:06

MatthewMartin