从 Cloudant 数据库中删除大量文档的最佳方法是什么?

发布于 2025-01-09 06:10:43 字数 63 浏览 1 评论 0原文

如果您要从 Cloudant 数据库中删除大量文档(例如 200 万个),最好是批量删除调用,还是还有其他方法?

If you are deleting a large number of documents from a Cloudant database, say 2 million, is it best to batch the delete calls, or is there another approach?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

有深☉意 2025-01-16 06:10:43

是的,使用 _bulk_docs 请求批量删除是解决此问题的最佳方法。提出 200 万个单个文档删除请求是不切实际的。

删除只是新文档修订版设置了已删除标志的更新。

批量大小是一个折衷方案,不要太小,以尽量减少请求数量;并且不会太大,以免给服务器带来太多工作量。一千份文件是一个合理的起点。在此示例中,仍需要 2,000 次调用才能删除所有文档。

有关如何创建批处理并发出批量删除命令的示例,请参阅

Yes, batching the deletes with a _bulk_docs request is the best way to approach this. Making two million single document delete requests would be impractical.

Deletes are just updates where the new doc revision has the deleted flag set.

The batch size is a bit of a compromise between not too small, to minimise the number of requests; and not so large that it puts too much work on the server. A thousand documents is a reasonable starting point. In this example it would still require 2,000 calls to delete all the documents.

For an example of how to create a batch and issue a bulk delete command see this blog post.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文