-
Type:
Improvement
-
Resolution: Fixed
-
Priority:
Trivial - P5
-
Affects Version/s: None
-
Component/s: Distributed Query Execution
-
None
-
Query Execution
-
Fully Compatible
-
QE 2025-02-03
-
None
-
None
-
None
-
None
-
None
-
None
-
None
ClusterClientCursor currently has the following method to stash a ClusterQueryResult onto a queue:
virtual void queueResult(const ClusterQueryResult& result) = 0;
The ClusterQueryResult is passed by const reference here, and the implementations copy it onto the stash.
ClusterQueryResult consists of two boost::optional}}s, one with a {{BSONObj and one with a ShardId. The ShardId type wraps an std::string, so it may be expensive to copy it.
Instead of copying the result onto the stash, we should rather move it. This is safe because stashing is only done when the result cannot be processed immediately. Thus the ownership is effectively transferred to the stash anyway.
Unstashing can also be optimized by {{std::move}}ing the results from the stash instead of copying them out.
While on this, we can also can slightly improve the signature of two other methods in the same area and mark them as const, as they are not modifying any data:
virtual bool remotesExhausted() = 0; virtual bool hasBeenKilled() = 0;