If I supply a hint and specify my index, it works as expected, or if I remove the boolean fields - it again works as expected. It seems isolated to searching on those boolean flags, if I remove those and instead query another field with a string, it again works.
Any ideas here? I don't believe you can pass a .hint() to an aggregation query...
mongos> db.visit.find({ "
site.id": 253, "frt": { $gte: new Date(2012, 08, 18 ) }, "test": false, "bot": false }).explain()
Tue Sep 18 15:05:56 08 is not a legal ECMA-262 octal constant (shell):1
{
"clusteredType" : "ParallelSort",
"shards" : {
"dynotrax1/s1.dynotrax:2100,s2.dynotrax:2100,s3.dynotrax:2100" : [
{
"cursor" : "BtreeCursor site.id_1_frt_1",
"isMultiKey" : false,
"n" : 31429,
"nscannedObjects" : 32230,
"nscanned" : 32230,
"nscannedObjectsAllPlans" : 32432,
"nscannedAllPlans" : 32432,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : 81,
"nChunkSkips" : 0,
"millis" : 555,
"indexBounds" : {
[
253,
253
]
],
"frt" : [
[
ISODate("2012-09-18T07:00:00Z"),
ISODate("292278995-01--2147483647T07:12:56.808Z")
]
]
},
"server" : "ip-10-6-50-253:2100"
}
]
},
"cursor" : "BtreeCursor site.id_1_frt_1",
"n" : 31429,
"nChunkSkips" : 0,
"nYields" : 81,
"nscanned" : 32230,
"nscannedAllPlans" : 32432,
"nscannedObjects" : 32230,
"nscannedObjectsAllPlans" : 32432,
"millisShardTotal" : 555,
"millisShardAvg" : 555,
"numQueries" : 1,
"numShards" : 1,
"indexBounds" : {
[
253,
253
]
],
"frt" : [
[
ISODate("2012-09-18T07:00:00Z"),
ISODate("292278995-01--2147483647T07:12:56.808Z")
]
]
},
"millis" : 557
}
This second query confuses me, changing the site.id value causes Mongo to only use the first part of my compound index and wildcards the Date field: mongos> db.visit.find({ "
site.id": 128, "frt": { $gte: new Date(2012, 08, 18 ) }, "ue": false, "bot": false }).explain()
Tue Sep 18 15:06:45 08 is not a legal ECMA-262 octal constant (shell):1
{
"clusteredType" : "ParallelSort",
"shards" : {
"dynotrax2/s1.dynotrax:2200,s2.dynotrax:2200,s3.dynotrax:2200" : [
{
"cursor" : "BtreeCursor site.id_1_lrt_-1",
"isMultiKey" : false,
"n" : 312,
"nscannedObjects" : 48710,
"nscanned" : 48710,
"nscannedObjectsAllPlans" : 49267,
"nscannedAllPlans" : 49267,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : 433,
"nChunkSkips" : 0,
"millis" : 5152,
"indexBounds" : {
[
128,
128
]
],
"lrt" : [
[
{
"$maxElement" : 1
},
{
"$minElement" : 1
}
]
]
},
"server" : "ip-10-4-211-107:2200"
}
]
},
"cursor" : "BtreeCursor site.id_1_lrt_-1",
"n" : 312,
"nChunkSkips" : 0,
"nYields" : 433,
"nscanned" : 48710,
"nscannedAllPlans" : 49267,
"nscannedObjects" : 48710,
"nscannedObjectsAllPlans" : 49267,
"millisShardTotal" : 5152,
"millisShardAvg" : 5152,
"numQueries" : 1,
"numShards" : 1,
"indexBounds" : {
[
128,
128
]
],
"lrt" : [
[
{
"$maxElement" : 1
},
{
"$minElement" : 1
}
]
]
},
"millis" : 5208
}
Last query, searching by the same site.id and filtering by another field, non-boolean, it works: mongos> db.visit.find({ "
site.id": 128, "frt": { $gte: new Date(2012, 08, 18 ) }, "tv": 1 }).explain()
Tue Sep 18 15:18:15 08 is not a legal ECMA-262 octal constant (shell):1
{
"clusteredType" : "ParallelSort",
"shards" : {
"dynotrax2/s1.dynotrax:2200,s2.dynotrax:2200,s3.dynotrax:2200" : [
{
"cursor" : "BtreeCursor site.id_1_frt_1",
"isMultiKey" : false,
"n" : 750,
"nscannedObjects" : 787,
"nscanned" : 787,
"nscannedObjectsAllPlans" : 989,
"nscannedAllPlans" : 989,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : 0,
"nChunkSkips" : 0,
"millis" : 15,
"indexBounds" : {
[
128,
128
]
],
"frt" : [
[
ISODate("2012-09-18T07:00:00Z"),
ISODate("292278995-01--2147483647T07:12:56.808Z")
]
]
},
"server" : "ip-10-4-211-107:2200"
}
]
},
"cursor" : "BtreeCursor site.id_1_frt_1",
"n" : 750,
"nChunkSkips" : 0,
"nYields" : 0,
"nscanned" : 787,
"nscannedAllPlans" : 989,
"nscannedObjects" : 787,
"nscannedObjectsAllPlans" : 989,
"millisShardTotal" : 15,
"millisShardAvg" : 15,
"numQueries" : 1,
"numShards" : 1,
"indexBounds" : {
[
128,
128
]
],
"frt" : [
[
ISODate("2012-09-18T07:00:00Z"),
ISODate("292278995-01--2147483647T07:12:56.808Z")
]
]
},
"millis" : 17
}
visit collection indexes: