Reputation: 177
My app uses a SQLite database with FTS3 to do product search. I am trying to encrypt the database using SQLCipher but it causes the database size to balloon (7mb --> ~20mb).
It doesn't look like there is a great way to compress an encrypted FTS SQLite database. Does anyone have a suggestion on this? I have to shrink it in order to keep the app under the 20mb 3g download limit.
Thanks!
Upvotes: 3
Views: 979
Reputation: 1523
There is no reason that a database using SQLCipher would be that large in comparison to one without SQLCipher. Each page of the SQLCipher database only uses 48 bytes of the page for IV and HMAC. Thus with a 1024 byte page size, if you had a 7mb unencrypted database, the SQLCipher encrypted version should be only 7.34 mb.
A far more likely explanation is that your database has grown as a result of deletes and inserts. If auto vacuum is not enabled on the database, deleted rows can continue to take up space. Try running VACUUM on the database to reclaim space.
If vacuuming the database doesn't take care of it, here are a few follow-up questions;
To answer your general question, a SQLCipher database is probably not going to compress well. If the file size growth is actually a result of FTS3 and not SQLCipher, then you could consider shipping the data on the app and then building the FTS3 virtual table on the device.
Upvotes: 1