-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Optimization
The runCountOnView and runExplainOnView are performing the same operation, however they use different logic, this ticket aims to address this mismatch.
Currently, `runCountOnView` takes as input the opCtx and the request. It creates the AggregateCommandRequest and then serializes the aggregate command into BSON in order to create an opMsgRequest. Then, it calls `runCommandDirectly` which takes as input the opCtx and the opMsgRequest. On the other hand, `runExplainOnView`, takes in the opCtx, the count command request, and the verbosity. It creates the aggregation command request and then calls `runAggregate` to execute.
We should consider using the same execute function for both `runExplainOnView` and `runCountOnView` so the critical paths are more similar. 'runCommandDirectly' requires serializing the aggregate command into BSON, while runAggregate does not require this serialization. Addressing the mismatch in the underlying execution logic should also address the performance implication of serializing the aggregate command to BSON.