views:

797

answers:

2

By design, Core Data does not issue a VACUUM SQL command to its SQLite database(s), as detailed here. I'm creating a Core Data application that'll store, and later delete, large binary files (2-10MB in size) in a SQLite db. Over time this will lead to fragmentation and a larger-than-necessary SQLite database. I'd like to periodically issue a VACUUM command, say, during a cleanup operation I run.

  • How can I progmatically issue a VACUUM command to Core Data's SQLite stores?
  • Is it possible to do this through Core Data, or must I mount the SQLite db and connect to it directly to execute the VACUUM SQL?
+1  A: 

The supported way to do this, on 10.6 and later, is to set the NSSQLiteManualVacuumOption in the options when you are adding the store to the persistent store coordinator.

Jim Correia
Thanks Jim! I take it this doesn't work in 10.5, correct?
Dave Gallagher
+1  A: 
amphetamachine