javascript bulk inset update
Posted tonggc1668
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript bulk inset update相关的知识,希望对你有一定的参考价值。
single bson is 1K
bulk insert 1k 96ms
update 1k without index bulkwrite 877ms bulkupdate 910ms
update 1k with index bulkwrite 107ms bulkupdate 120ms
bulk insert 10k 592ms
update 10k with index bulkwrite 1045ms bulkupdate 1200ms
bulk insert 100k 30025ms 25834ms
update 1k with index bulkwrite unorderd 109ms
update 10k with index bulkwrite unorderd 998ms
update 10k with index bulkwrite 1252ms bulkupdate 1555ms
update 100k with index bulkwrite unorderd 11654ms
try { db.restaurant.updateMany( { "name" : "Pizza Rat‘s Pizzaria" }, { $inc: { "violations" : 3}, $set: { "Closed" : true } }, { w: "majority", wtimeout: 100 } ); } catch (e) { print(e); } try { db.CollateralRepresentationBulkTest.bulkWrite( [ { updateMany : { "filter" : { "uicid" : "170484_SMCP_1001059_20200131_20200302" }, "update" : { $set : { "xipEnvId" : "test2" } } } }, { updateMany : { "filter" : { "uicid" : "170484_SMCP_100159930_20200131_20200302" }, "update" : { $set : { "xipEnvId" : "test2" } } } } ] //,{ writeConcern : { w : "majority", wtimeout : 20 }, ordered : false } ); } catch (e) { print(e); }
var ops = []; try { var trades = db.CollateralRepresentationBulkTest.find({},{ uicid: 1, _id: 0 }).limit(1000); while(trades.hasNext()){ ops.push( { updateMany : { "filter" : { "uicid" : trades.next().uicid }, "update" : { $set : { "xipEnvId" : "test" } } } } ); } var startTime = (new Date()).getTime(); db.CollateralRepresentationBulkTest.bulkWrite( ops //,{ writeConcern : { w : "majority", wtimeout : 100 }, ordered : false } ); var runTime = (new Date()).getTime()-startTime; print("Finished, runTime is "+runTime+"ms"); } catch (e) { print(e); }
tmDb = db.getSiblingDB(‘timemachine‘); try{ var trades = tmDb.CollateralRepresentationBulkTest.find({}).limit(1000); var bulk = tmDb.CollateralRepresentationBulkTest.initializeUnorderedBulkOp(); var startTime = (new Date()).getTime(); while(trades.hasNext()){ bulk.find( { uicid: trades.next().uicid } ).update( { $set: { xipEnvId: "test" } } ); } bulk.execute(); var runTime = (new Date()).getTime()-startTime; print("Finished, runTime is "+runTime+"ms"); }catch (e){ print (e); }
tmDb = db.getSiblingDB(‘timemachine‘); db.CollateralRepresentationBulkTest.drop(); try{ var trades = tmDb.CollateralRepresentation.find({}).limit(1000); var bulk = tmDb.CollateralRepresentationBulkTest.initializeUnorderedBulkOp(); while(trades.hasNext()){ bulk.insert(trades.next()); } var startTime = (new Date()).getTime(); bulk.execute(); var runTime = (new Date()).getTime()-startTime; print("Finished, runTime is "+runTime+"ms"); tmDb.CollateralRepresentationBulkTest.createIndex({"uicid":1, },{background : true}) }catch (e){ print (e); }
以上是关于javascript bulk inset update的主要内容,如果未能解决你的问题,请参考以下文章
将 calc() 与 env(safe-area-inset) 一起使用
py-elasticsearch的stream_bulk、parallel_bulk、bulk性能对比