-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
storage: optimize multiple objects write
Previously multiple objects write required 2 round trips to DB per object: one to fetch object state from DB and second to update object. Each query is indexed and fast, but with latency to DB comparable to query execution time it adds significant overhead. This change optimizes multiple objects write in 2 steps: 1. Instead of reading DB state for each object and then deciding on possible write operation, perform write operation unconditionally with correct predicates (version and permissions) defined where applicable. That said write operation might not succeed if row doesn't match predicate. Write query is structured in such way, that final state of the row in the database is returned, regardless whether writeop successed or not. By inspecting returned row we can infer whether it was success, version conflict or permission error. 2. Now that each object is written to DB in a single query, there is no dependencies between queries and all of them can be blasted to DB in a batch without waiting for result of each. Whole batch continues to be executed in a single transaction, so outcome is the same, but batching negates latency penalty.
- Loading branch information
Showing
1 changed file
with
147 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters