1.3.13. /db/_compact
¶
-
POST
/{db}/_compact
¶ 请求压缩指定的数据库。压缩通过执行以下操作压缩磁盘数据库文件:
- 写入数据库文件的新的优化版本,在写入期间从新版本中删除任何未使用的部分。因为为此目的临时创建了一个新文件,所以要完成压缩例程,您可能需要最多两倍于指定数据库的当前存储空间。
- 从数据库中删除文档的任何非叶修订的正文。
- 删除超出指定限制的旧修订历史记录
_revs_limit
数据库参数。
只能对单个数据库请求压缩;不能压缩CouchDB实例的所有数据库。压缩过程作为后台进程运行。
通过获取数据库元信息,可以确定压缩过程是否在数据库上运行
compact_running
返回的数据库结构的值将设置为true。看到了吗 :get:`/{{db}}` .还可以获取正在运行的进程的列表,以确定压缩当前是否正在运行。看到了吗 /_active_tasks .
参数: - db -- 数据库名称
请求标头: - Accept --
- application/json
- text/plain
- Content-Type -- application/json
响应头: - Content-Type --
- application/json
- text/plain; charset=utf-8
响应JSON对象: - ok (boolean) -- 运行状态
状态代码: - 202 Accepted -- 已接受压实请求
- 400 Bad Request -- 数据库名称无效
- 401 Unauthorized -- 需要CouchDB服务器管理员权限
- 415 Unsupported Media Type -- 坏的 Content-Type 价值
请求 :
POST /db/_compact HTTP/1.1 Accept: application/json Content-Type: application/json Host: localhost:5984
响应 :
HTTP/1.1 202 Accepted Cache-Control: must-revalidate Content-Length: 12 Content-Type: application/json Date: Mon, 12 Aug 2013 09:27:43 GMT Server: CouchDB (Erlang/OTP) { "ok": true }
1.3.14. /db/_compact/design-doc
¶
-
POST
/{db}/_compact/{ddoc}
¶ 压缩与指定设计文档关联的视图索引。压缩一个大视图可能比压缩实际的数据库返回更多的存储空间。因此,如果您知道最近的数据库更改影响了一组特定的视图索引,那么您可以使用它来代替完整的数据库压缩。
参数: - db -- 数据库名称
- ddoc -- 设计文件名称
请求标头: - Accept --
- application/json
- text/plain
- Content-Type -- application/json
响应头: - Content-Type --
- application/json
- text/plain; charset=utf-8
响应JSON对象: - ok (boolean) -- 运行状态
状态代码: - 202 Accepted -- 已接受压实请求
- 400 Bad Request -- 数据库名称无效
- 401 Unauthorized -- 需要CouchDB服务器管理员权限
- 404 Not Found -- 找不到设计文档
- 415 Unsupported Media Type -- 坏的 Content-Type 价值
请求 :
POST /db/_compact/posts HTTP/1.1 Accept: application/json Content-Type: application/json Host: localhost:5984
响应 :
HTTP/1.1 202 Accepted Cache-Control: must-revalidate Content-Length: 12 Content-Type: application/json Date: Mon, 12 Aug 2013 09:36:44 GMT Server: CouchDB (Erlang/OTP) { "ok": true }
注解
视图索引存储在单独的
.couch
基于哈希文件的设计文档的相关函数,在主目录的子目录中.couch
数据库文件位于。
1.3.15. /db/_ensure_full_commit
¶
-
POST
/{db}/_ensure_full_commit
¶ 在 3.0.0 版更改: 已弃用;终结点是禁止操作的。
在3.0之前,它用于提交最近对数据库的更改,以防
delayed_commits=true
选项已设置。这个选择总是false
现在,提交永远不会延迟。但是,保留此端点是为了与旧的复制器兼容。参数: - db -- 数据库名称
请求标头: - Accept --
- application/json
- text/plain
- Content-Type -- application/json
响应头: - Content-Type --
- application/json
- text/plain; charset=utf-8
响应JSON对象: - instance_start_time (string) -- 总是
"0"
. (由于遗留原因而返回。) - ok (boolean) -- 运行状态
状态代码: - 201 Created -- 提交已成功完成
- 400 Bad Request -- 数据库名称无效
- 415 Unsupported Media Type -- 坏的 Content-Type 价值
请求 :
POST /db/_ensure_full_commit HTTP/1.1 Accept: application/json Content-Type: application/json Host: localhost:5984
响应 :
HTTP/1.1 201 Created Cache-Control: must-revalidate Content-Length: 53 Content-Type: application/json Date: Mon, 12 Aug 2013 10:22:19 GMT Server: CouchDB (Erlang/OTP) { "instance_start_time": "0", "ok": true }
1.3.16. /db/_view_cleanup
¶
-
POST
/{db}/_view_cleanup
¶ 删除CouchDB不再需要的视图索引文件,这些文件是设计文档中视图更改的结果。由于视图文件名基于视图函数的散列,随着时间的推移,旧视图将保留下来,消耗存储空间。此调用清除磁盘上给定视图的缓存视图输出。
参数: - db -- 数据库名称
请求标头: - Accept --
- application/json
- text/plain
- Content-Type -- application/json
响应头: - Content-Type --
- application/json
- text/plain; charset=utf-8
响应JSON对象: - ok (boolean) -- 运行状态
状态代码: - 202 Accepted -- 已接受压实请求
- 400 Bad Request -- 数据库名称无效
- 401 Unauthorized -- 需要CouchDB服务器管理员权限
- 415 Unsupported Media Type -- 坏的 Content-Type 价值
请求 :
POST /db/_view_cleanup HTTP/1.1 Accept: application/json Content-Type: application/json Host: localhost:5984
响应 :
HTTP/1.1 202 Accepted Cache-Control: must-revalidate Content-Length: 12 Content-Type: application/json Date: Mon, 12 Aug 2013 09:27:43 GMT Server: CouchDB (Erlang/OTP) { "ok": true }