-
Type: Bug
-
Resolution: Fixed
-
Priority: Minor - P4
-
Affects Version/s: 2.14.0
-
Component/s: None
-
None
-
Fully Compatible
Queries of the form `MyCollection.where(...).hint(...).count` run an aggregation pipeline to determine the size without passing on the index hint. In cases where the query is sufficiently complicated the server will use the wrong index and the query times out.
I tracked down the issue to `Mongo::Collection::View::Readable#count_documents` where the aggregation pipeline `opts` do not include the view's `options[:hint]`. Adding `opts[:hint] = options[:hint]` before the aggregation pipeline runs seems to resolve the issue.
I'm not sure why all of the view options are not currently used for `count_documents`, but it certainly seems like a bug to not respect the index hint provided.
- is duplicated by
-
RUBY-2565 skip/limit not respected by count
- Closed
- related to
-
RUBY-2706 Find options are not correctly propagated in a number of cases
- Closed
-
MONGOID-5428 Set driver options in mongoid.yml
- Closed