-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 2.2.2
-
Component/s: Querying
-
Major Change
-
ALL
In some cases, sorting a query results in the use of a sparse index, which in turn results in a lesser number of documents being returned than would normally be returned by the query. This strikes me as incorrect.
Example:
Suppose I have a collection "foo" that contains 1000 documents. 750 of those documents include a value for the field "bar", while the other 250 do not. Suppose I have a sparse index "bar_1" on the field "bar". The index will contain the 750 documents that have a value for the field.
The following query results in 1000 documents:
db.foo.find()
The following query results in only 750 documents, despite the identical query parameters:
db.foo.find().sort(
)
I understand why this behaves the way it does, but in my opinion the behavior is incorrect.
- is duplicated by
-
SERVER-13549 MongoDB 2.6 doesn't automatically use sparse index
- Closed
- related to
-
SERVER-11568 query optimizer fails to use index when sort spec is inconsistent with index spec
- Closed