Open
Description
Is your feature request related to a problem? Please describe.
Aggregation is always used even in queries where find()
would have been sufficient.
In general, find()
is often faster than using the aggregation framework and always makes use of indexes. The $match
stage for aggregation can only use an index to filter documents if it occurs at the beginning of a pipeline which is not always the case.
Describe the solution you'd like
There is already some work in place in the Calcite adapter to determine a filter and projection document for a possible find()
operation but these values are not used. If the query does not require additional operations that are only supported in the aggregation framework then the query execution should be done using find()
.