MongoDB Batch update performance problems -


i understand mongodb supports batch inserts, not batch updates.

batch-inserting thousands of documents pretty fast, updating thousands of documents incredibly slow. slow workaround i'm using remove old documents , batch-insert updated documents. had add flags mark them invalid , stuff required compensating failed mock 'bulk update'. :(

i know awful , unsafe solution, way i've been able reach required performance.

if know better way, please me.

thanks!

as long you're using mongodb v2.6 or higher, can use bulk operations perform updates well.

example the docs:

var bulk = db.items.initializeunorderedbulkop(); bulk.find( { status: "d" } ).update( { $set: { status: "i", points: "0" } } ); bulk.find( { item: null } ).update( { $set: { item: "tbd" } } ); bulk.execute(); 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -