Details
-
Bug
-
Resolution: Done
-
Critical - P2
-
3.0.10, 3.2.4
-
None
-
Fully Compatible
-
ALL
-
Query 13 (04/22/16)
Description
Issue Summary
With a schema and index such as the following:
|
Schema |
{
|
b : 1,
|
d : [{
|
e: 3,
|
f: {
|
type : "Point", |
coordinates:[-2, 53]
|
}
|
}
|
]
|
}
|
|
Index |
{
|
"b" : 1, |
"d.e" : 1, |
"d.f": "2dsphere" |
}
|
A query on these fields using elemMatch on d results in a COLLSCAN for 2dsphereIndexVersion 2 and 3 on both 3.0.10 and 3.2.4. Keeping everything else identical and switching to 2dsphereIndexVersion 1 results in the planner correctly using the index with the expected bounds.
Reproduction
Run the following script and verify that the explain output is a COLLSCAN. Then, change the 2dsphereIndexVersion to 1 and re-run.
|
indexTest.geo.min.js |
db.indextest.drop();
|
|
|
var row = { |
b : 1,
|
d : [{
|
e: 3,
|
f: {
|
type : "Point", |
coordinates:[-2, 53]
|
}
|
}
|
]
|
};
|
|
|
db.indextest.createIndex({
|
"b" : 1, |
"d.e" : 1, |
"d.f": "2dsphere" |
},{
|
"2dsphereIndexVersion": 2 |
});
|
|
|
db.indextest.save(row);
|
|
|
var query = { |
b : 1,
|
d : {
|
$elemMatch : {
|
e : 3,
|
f:{
|
$geoWithin : {
|
$centerSphere : [[-2, 53], 2.523219554550177E-4]
|
}
|
}
|
}
|
}
|
};
|
|
|
var explain = db.indextest.find(query).explain(); |
var count = db.indextest.find(query).count(); |
|
|
printjson(explain);
|
printjson( { "count" : count } ) |
Notes
- Hinting the index with 2dsphereIndexVersion 2 or 3 results in the index bounds being set to [MinKey,MaxKey]
Attached
- Repro script
- explain output for each 2dsphereIndexVersion, all on 3.2.4
Attachments
Issue Links
- is duplicated by
-
SERVER-22205 Index bounds are not populated for a compound index with 2dsphere in the end
-
- Closed
-