aws / aws/amazon-documentdb-jdbc-driver
[FEATURE] Use find() instead of aggregate() for simpler queries when possible to enhance performance
- Dominant language
- Java
- Stars
- 17
- Forks
- 16
- PR merge metrics
- No merged PRs in 30d
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()`.
## Additional context
- https://docs.aws.amazon.com/documentdb/latest/developerguide/best_practices.html#best_practices-indexes
Contributor guide
Research direction
Begin with the Calcite adapter and its existing logic for determining filter and projection documents. Trace how these values reach query execution and identify which queries require aggregation-only operations. Done means eligible queries use find(), while queries needing unsupported operations retain aggregation behavior, with index use and performance checked against the issue requirements.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100