[JAVA-341] On INSERT iterate over documents ONCE not TWICE Created: 30/Apr/11  Updated: 31/Mar/15  Resolved: 12/Jul/13

Status: Closed
Project: Java Driver
Component/s: Performance
Affects Version/s: 2.5.3
Fix Version/s: 3.0.0

Type: Improvement Priority: Major - P3
Reporter: Anatoly Polinsky Assignee: Unassigned
Resolution: Done Votes: 2
Labels: concurrency, insert
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

N/A


Attachments: Text File insert_to_only_pass_through_docs_ONCE_on_creating_batches_and_creating_IDs.patch    

 Description   

Currently DBApiLayer iterates through documents TWICE in case '_id's have to be created ( "shouldApply" is true ): once to set "_id"s and the second time to create batch chunks.
This slows down the insert ( with any WriteConcern ).

Attaching a patch that optimizes the INSERT: now documents are iterated only ONCE without changing a current behavior.

/Anatoly

P.S. I am currently testing with application level partitioning, so different partitions actually sent to the different mongoDs in real time ( even distribution ): https://github.com/anatoly-polinsky/mongodb-write-performance-playground and the patch does help to boost the performance.



 Comments   
Comment by Jeffrey Yemin [ 31/Mar/15 ]

Closing all resolved 3.0.0 issues, as 3.0.0 has been tagged and released.

Comment by Jeffrey Yemin [ 12/Jul/13 ]

Fixed in 3.0.x branch: https://github.com/mongodb/mongo-java-driver/commit/fac7ede#L18R45

Generated at Thu Feb 08 08:52:03 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.