My mongodb is rather simple: a dataset/entry has around 30 properties on 3 layers. One such entry has up to around 5000 characters. I have 500k of them. When I execute the following query...
db.images.find({ "featureData.cedd": { $exists: false}}).count()
...it is extremely slow. It's not indexed, but still.. from my MySQL experience it shouldn't take 20 minutes to execute one such query.
While being executed (directly on the mongo terminal) there's 3% CPU usage and still over 2 Gigs of free memory.
Thanks for giving me a hint on what I could do!
EDIT: An explain() of the query (without count) gives:
db.images.find({ "featureData.cedd": { $exists: false }}).explain()
{
"cursor" : "BasicCursor",
"nscanned" : 532537,
"nscannedObjects" : 532537,
"n" : 438,
"millis" : 1170403,
"nYields" : 0,
"nChunkSkips" : 0,
"isMultiKey" : false,
"indexOnly" : false,
"indexBounds" : {
}
}
Output of iostat:
Linux 3.2.0-58-generic (campartex) 03/25/2014 _x86_64_ (2 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
34.93 0.01 0.25 0.48 0.00 64.33
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
sda 2.08 103.79 11.26 172805914 18749067
fd0 0.00 0.00 0.00 148 0
Output of explain() after adding an index:
db.images.find({ "featureData.cedd": { $exists: false }}).explain()
{
"cursor" : "BtreeCursor featureData.cedd_1",
"nscanned" : 438,
"nscannedObjects" : 438,
"n" : 438,
"millis" : 2,
"nYields" : 0,
"nChunkSkips" : 0,
"isMultiKey" : true,
"indexOnly" : false,
"indexBounds" : {
"featureData.cedd" : [
[
null,
null
]
]
}
}
explain
ing the query is always a good first step