Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite database gets larger after vacuum

Tags:

sqlite

As part of refreshing some of the customer records in my sqlite database, I deleted a load of records and then imported some from an imported table. I then deleted the temp table and did a vacuum. The file was around 6mb before vacuuming and then 10mb after vacuuming. I did an integrity check and it seems ok. I did another test and if I don't vacuum, the file size is still about 6mb.

Am I doing something wrong?

(I've been doing the vacuum using a SQLite Manager. When using SQLiteSpy, however, it works properly. So it seems to be a problem with SQLite Manager. Might be of use to someone who has a similar problem)

like image 738
alj Avatar asked Dec 15 '11 21:12

alj


People also ask

How do I reduce the size of my SQLite database?

Try to zip it and use zipinput stream while unpacking your database from assets. Anyway, android will zip your 14mb database when you create your apk anyway (which will be unzipped during install), so I guess your apk will be around 5-6mb in size. Android will zip automatically when creating/exporting apk file?

What does VACUUM do in SQLite?

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.

Does SQLite compress data?

The SQLite Compressed and Encrypted Read-Only Database (CEROD) Extension is an add-on to the public domain version of SQLite that allows an application to read compressed and encrypted database files in addition to ordinary SQLite database files.

How big can SQLite DB get?

SQLite database files have a maximum size of about 140 TB. On a phone, the size of the storage (a few GB) will limit your database file size, while the memory size will limit how much data you can retrieve from a query. Furthermore, Android cursors have a limit of 1 MB for the results.


1 Answers

It's a bug with SQLite Manager. See my comments in the original post. Works when using another tool like SQLiteSpy.

like image 82
alj Avatar answered Oct 23 '22 05:10

alj