Following code gives me some trouble:
/**
*
* finds all distinct values of HybridTypes for the Page Collection
*/
def findDistinctTypeValues(): List[String] = {
//cast all instances from Any to String
val coll = dao.collection.distinct("hybridType") map (_.asInstanceOf[String])
coll.toList
}
The mongo console tells me that the corresponding query lasts about 4 seconds. The field is an indexed string.
Is there anything im doing particularly wrong?
Update: This is the output of the runcommand:
db.runCommand({distinct: 'pages',key:'hybridType'})
"stats" : {
"n" : 2492192,
"nscanned" : 2492192,
"nscannedObjects" : 0,
"timems" : 4247,
"cursor" : "BtreeCursor hybridType_1"
},
"ok" : 1
Looks like its performing a full table scan? :/