如何VACUUM核心数据SQLite数据库? [英] How to VACUUM a Core Data SQLite db?

查看:159
本文介绍了如何VACUUM核心数据SQLite数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照设计,Core Data不会向其SQLite数据库发出 VACUUM SQL命令,因为这里详述。我正在创建一个Core Data应用程序,它将在SQLite数据库中存储并随后删除大型二进制文件(大小为2-10MB)。随着时间的推移,这将导致碎片和一个大于必要的SQLite数据库。我想在我运行的清理操作期间定期发出一个VACUUM命令。

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.


  • 如何预先发出VACUUM命令

  • 是否可以通过Core Data执行此操作,或者必须安装SQLite数据库并直接连接到它以执行VACUUM SQL?
  • b $ b

推荐答案

在OS X 10.6 / iOS 3.0及更高版本上支持的方法是设置< a href =https://developer.apple.com/library/mac/documentation/Cocoa/Reference/CoreDataFramework/Classes/NSPersistentStoreCoordinator_Class/index.html#//apple_ref/doc/constant_group/Store_Options =nofollow noreferrer > NSSQLiteManualVacuumOption 在您将存储添加到持久存储协调器时的选项。

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

这篇关于如何VACUUM核心数据SQLite数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆