How to VACUUM a Core Data SQLite db?(如何 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 数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何 VACUUM 核心数据 SQLite 数据库?


- SQL 临时表问题 2022-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 更改自动增量起始编号? 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01