1
0
Fork 0
mirror of https://github.com/Luzifer/clean_couch.git synced 2024-11-08 14:00:07 +00:00
No description
Find a file
2015-06-20 23:12:29 +02:00
.gitignore Initial version 2015-06-20 23:12:29 +02:00
LICENSE Initial version 2015-06-20 23:12:29 +02:00
main.go Initial version 2015-06-20 23:12:29 +02:00
README.md Initial version 2015-06-20 23:12:29 +02:00

Luzifer / clean_couch

License: Apache 2.0

This utility emerged from the need to delete about 20k documents from a CouchDB database with more than 600k documents. As I did not want to delete every document by hand and had no other way to delete documents by a specific filter.

Usage

  1. Create a view which filters the documents in your database with exactly this emit line you can see in this example
function(doc) {
  if (doc.user == "usertodelete") {
    emit(doc._rev, null);
  }
}
  1. Execute with parameters
# ./clean_couch
Usage of ./clean_couch:
      --baseurl="http://localhost:5984": BaseURL of your CouchDB instance
      --concurrency=50: How many delete requests should get processed concurrently?
      --database="": The database containing your view and the data to delete
      --view="": The view selecting the data to delete

# ./clean_couch --database=userdata --view=_design/del/_view/usertodelete

Warnings

  • If you set the concurrency above 1024 either clean_couch or even the CouchDB server might break because of a limit in open file descriptors
  • If the database has many views you could overload your server because views need to get recalculated
    (My CouchDB server survived a concurrency of 100 with minimal load)