Reputation: 23787
I have a service that creates records in the apps' SQLite DB, processes data, and removes records from the SQLite DB.
I've found that the SQLite DB has grown over time (maybe a week) eventhough the amount of records in it has remained fairly constant.
Question What is the best practice to add and remove records without growing the database ?
To insert a record I use:
result = mDB.insert(table, null, kvpairs);
To remove a record I use:
result = mDB.delete(table, where, null);
reference
Upvotes: 3
Views: 641
Reputation: 180080
Free pages in the database will be reused, so the growth will not be unlimited.
You could try updating records in place, but this will not help if you cannot map old to new records or if some values change their size.
Try running VACUUM regularly, and/or enabling PRAGMA auto_vacuum.
Upvotes: 4