-
Type: Question
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 1.6.4
-
Component/s: None
-
None
From the mailing list:
db.test.insert(
);
db.test.insert(
);
db.test.ensureIndex(
)
// Uses an index
db.test.find({$or : [{ parts :
},
{ parts : "part4" }]}).explain()
// Does not use an index
db.test.find({$or : [{ parts :
},
{ parts : "part4" }]}).sort(
{ priority : -1 }).explain()
// Uses the index, but doesn't produce expected explain output
db.test.find({$or : [{ parts :
},
{ parts : "part4" }]}).sort(
{ priority : -1 }).hint(
{parts: 1, priority: -1}).explain()
// Here's the output (it's NOT in the form of the typical $or-like explain plan)
{
"cursor" : "BtreeCursor parts_1_priority_-1",
"nscanned" : 7,
"nscannedObjects" : 7,
"n" : 2,
"scanAndOrder" : true,
"millis" : 0,
"indexBounds" : {
"parts" : [
[
,
{ "$maxElement" : 1 } ]
],
"priority" : [
[
,
{ "$minElement" : 1 } ]
]
}
}
- duplicates
-
SERVER-1205 $or sort does not use index ranges expressed in or clauses
- Closed