'What is the best way to delete large numbers of documents from a Cloudant database?
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?
Solution 1:[1]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Daniel Mermelstein |
