I am using a SQLite backed core data store for an iPhone app I am currently developing.
I was wondering how database maintenance is handled with SQLite on iPhone if at all? Server based RDBMS systems usually require regular defragmentation and statistics updates etc to ensure consistent performance. I’m not sure how this is handled on mobile devices.
How is this handled in iOs and SQLite.? Is there anything that needs to be done on the part of the developer or is it all handled automatically?
My database will contains at most 100,000 records with approximately 500 inserts or deletes a day.
SQLite has the
ANALYZEcommand to update statstics, but it is unlikely that it would have much of an effect in a small database like yours. You could check withEXPLAIN QUERY PLANwhether there is any difference. (In any case, it wouldn’t hurt.)To defragment, you can use the
VACUUMcommand. However, on flash-based storage, fragmentation is much less of a problem than the time where the database is blocked by a complete reorganization would be.In practice, database maintenance is almost never worth the bother on handheld devices.