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 Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01