-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Performance
-
Labels:
Use Case
As a Node.js driver user performing using toArray on my cursors
I want to lower the cost of iterating through each document
So that I can get better performance from the API
This optimization exists in v3:
https://github.com/mongodb/node-mongodb-native/blob/v3.7.4/lib/cursor.js#L861-L864
User Impact
- Performance improvement
Dependencies
- All cursor usages but no functional change
Unknowns
- Internally representing the change in Typescript
Acceptance Criteria
Implementation Requirements
- Update toArray to:
- consume entire batches as they arrive
- use arrays returned from BSON to extend the local array being built (do not use LL)
- toArray can apply document transformations to the final array if a transform was given
- Address the following associated tech debt:
- Move kDocuments to private "documents"
- Store calculated getMoreOptions
- only a runCursorCommand cursor can change getMore options after the first getMore operation
Testing Requirements
- Assert arrays from BSON are used directly
- Assert List is not used for toArray
Documentation Requirements
- None
Follow Up Requirements
- None