I store a very long string to my document in mongodb server, my document looks like
{
"_id": ObjectId("5280efdbe4b062c93b582118"),
"viewID": 1,
"content": "a very long string"
}
and there are about hundreds of such documents in the same collection. I have indexed the collection.
The problem is that I just execute a very simple query
db.blog.find({viewID:1});
and then get a very long time (over several hours) to wait for the response, and no any error message displayed, server status is OK. But I just add db.blog.find({viewID:1}).limit(1);
mongodb returns the result at once.
How can I do to solve the problem or improve the performance??
Here is my explain:
db.blog.find({viewID:1}).explain();
{
"cursor" : "BtreeCursor viewID_1",
"isMultiKey" : false,
"n" : 377,
"nscannedObjects" : 377,
"nscanned" : 377,
"nscannedObjectsAllPlans" : 377,
"nscannedAllPlans" : 377,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : 0,
"nChunkSkips" : 0,
"millis" : 45,
"indexBounds" : {
"viewID" : [
[
1,
1
]
]
},
"server" : "Server:27017"
}
Here is colStat:
db.blog.stats();
{
"ns" : "***.blog",
"count" : 98582,
"size" : 2330759632,
"avgObjSize" : 23642.851960804204,
"storageSize" : 2958364672,
"numExtents" : 18,
"nindexes" : 2,
"lastExtentSize" : 778276864,
"paddingFactor" : 1,
"systemFlags" : 1,
"userFlags" : 0,
"totalIndexSize" : 6540800,
"indexSizes" : {
"_id_" : 4055296,
"viewID_1" : 2485504
},
"ok" : 1
}