本文介绍了如何 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.

  • 如何以编程方式向 Core Data 的 SQLite 存储区发出 VACUUM 命令?
  • 是否可以通过 Core Data 执行此操作,还是必须挂载 SQLite 数据库并直接连接到它才能执行 VACUUM SQL?

推荐答案

在 OS X 10.6/iOS 3.0 及更高版本上支持的方法是设置 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 数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 08:58
查看更多