db.location.find(
{ "$or": [
{ "country_lc": /^unit/, "docType": "country" },
{ "region_lc": /^unit/, "docType": "region" },
{ "city_lc": /^unit/, "docType": "city" }
]},
{ "country": 1, "region": 1, "city": 1, "docType" :1 }
).sort({ "country_lc" :1, "region_lc": 1, "city_lc":1 })
这是monodb中的查询花了很多时间。如何有效地查询?下面是上面查询的explain()输出。我在收集位置总共有442161个文件。我必须做一些前缀搜索。我已经完成了索引(country_lc,docType) ,(region_lc,docType),(city_lc,docType)和(country_lc,region_lc,city_lc)
{
"cursor" : "BtreeCursor country_lc_1_region_lc_1_city_lc_1",
"isMultiKey" : false,
"n" : 29,
"nscannedObjects" : 76935,
"nscanned" : 442161,
"nscannedObjectsAllPlans" : 76935,
"nscannedAllPlans" : 442161,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : 79,
"nChunkSkips" : 0,
"millis" : 81531,
"indexBounds" : {
"country_lc" : [
[
{
"$minElement" : 1
},
{
"$maxElement" : 1
}
]
],
"region_lc" : [
[
{
"$minElement" : 1
},
{
"$maxElement" : 1
}
]
],
"city_lc" : [
[
{
"$minElement" : 1
},
{
"$maxElement" : 1
}
]
]
},
"server" : "prashanta:27017"
}