I have a database where I need to remove documents with a regular interval. It is going to be in the ballpark of 100k documents per batch.

As of today that is achieved by first doing a request to a view which returns a list of the _id:s and _rev:s of the documents to be removed.

I then do a http DELETE request to hostname/database/_id?=_rev for each of those documents.

To me that seems ridiculously inefficient since I must do a http request for each of those 100k documents.

Is there any more efficient way of deleting large ammounts of documents in couch? I have been looking for a command similar to the POST for creating new documents, where you send the data in the body of the http. Or way of doing this in a mapreduce. But so far no luck.

有帮助吗?

解决方案

You can bundle all of the delete operations into one bulk_docs update.

For 100k documents, you will notice that the operation takes a little time, but it is much faster than individual DELETE updates.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top