我有一个同步过程,我正在使用Core Data来存储大量信息。有几次,我使用管理器下载了真正的SQLite数据库文件,以检查数据是否正确。
几天前,我意识到两个SQLite文件的大小差别很大。一个文件大小为80MB,另一个文件大小为100MB。当我用SQLite查看器检出其中的数据时,没有什么不同。相同的表,相同的索引,相同的行。这怎么可能呢?可能的情况是,当我通过Core Data删除对象时,某些数据仍在文件中
编辑:
解决方案是一个选项标志,它可以插入到选项NSDictionary中,并作为参数添加到addPersistentStore方法中。
NSSQLiteManualVacuumOption
Option key to rebuild the store file, forcing a database wide defragmentation when the store is added to the coordinator.
This invokes SQLite's VACUUM command. It is ignored by stores other than the SQLite store.发布于 2012-12-14 16:49:09
出于性能原因,Sqlite在删除数据时不会主动返回未使用的磁盘空间。这可能是你看到不同之处的原因。有关详细信息,请参阅此链接:
SQLite FAQ
https://stackoverflow.com/questions/13875255
复制相似问题