Details
-
Improvement
-
Resolution: Fixed
-
Major - P3
-
None
-
Fully Compatible
-
Query 2020-02-24, Query 2020-03-09
Description
Currently, the find or getMore commands tries to retrieve a postBatchResumeToken for each document in a batch, unconditionally calling PlanExecutor::getPostBatchResumeToken() even though the execution tree doesn't contain a stage which can produce the token.
Moreover, the implementation of the PlanExecutor::getPostBatchResumeToken() method is sub-optimal, as we traverse the entire execution tree trying twice to find either ChangeStreamProxyStage or CollectionScan.
Similarly is PlanExecutor::getLatestOplogTimestamp().
We can optimize these methods to avoid the need to traverse the execution tree over and over again, and only call these methods when we know upfront that the execution can produce a postBatchResumeToken or latestOpLogTimestamp.