ios - Delete multiple documents in CouchDB -


i've "best practice" question on couchdb (actually i'm using touchdb couchdb port ios), when using couchcocoa framework.

i need delete bunch of documents via query. know 3 ways this:

1) put documents nsarray, use [couchdatabase deletedocuments:]

2) foreach query rows call delete method, like: (couchqueryrow* row in query.rows) [row.document delete];

3) create query emit _id, _rev properties , add _deleted property, use bulk update, like: [couchdatabase putchanges:]

what's better performance-wise? there's better way it?

at http api level, fastest way achieve run single batch request provides _id , current _rev of documents removed.

your job make sure couchcocoa — know couchcocoa try cache _rev of documents reads, if deleting documents have been read, [couchdatabase deletedocuments:] should enough, otherwise have [couchdatabase getdocumentswithids:] first.

if documents large, might become better _rev using view instead of bulk fetch. forces use [couchdatabase putchanges:] perform bulk deletion. don't know document size threshold lies, have benchmark one.

of course, need decide happens when conflict occurs.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -