mongodb - Slow query when iterating for ID's over documents with binary data -


we required iterate on id's of documents in specific collection, these documents contain binary data field.

when query projection returns _id field, query takes approximately 80 seconds return 200000 results.

is there faster way cursor contains _id fields , doesn't degrade the size of binary data field? if remove data field of documents, query returns in few hundred milliseconds.

steps reproduce in mongo shell:

function randomstring() {      var chars = "0123456789abcdefghijklmnopqrstuvwxtzabcdefghiklmnopqrstuvwxyz";      var randomstring = '';      var string_length = 64000;     (var i=0; i<string_length; i++) {          var rnum = math.floor(math.random() * chars.length);          randomstring += chars.substring(rnum,rnum+1);      }      return randomstring;  }  var data = randomstring() (var = 1; <= 200000; i++) { db.testdata.insert({data: new bindata(0, data)}) }  var cursor = db.testdata.find({}, {_id: true}) cursor.foreach(printjson) 

it seems normal takes long... 75000ms in case.

why have iterate through _id? searching for? maybe can add timestamp or use timestamp integrated in id. limit selection or specify find-order.

ps.: aggregate-order has more options, if find not enough.


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -