mirror of
https://github.com/FerretDB/documentdb.git
synced 2026-11-25 11:49:53 -05:00
### Does this PR have any customer impact? ### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) ### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes) ### Are you introducing any new config? If yes, do you have tests with and without them being set? ### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md)) ### Description Improve update performance for unsharded collections on multi-node Before this change we were iterating the update batch on the coordinator and sending the individual update spec to the worker node, so if the batch was of 500, that meant 500 calls to the worker node and serializing/deserializing the update spec and the result. For unsharded collections we can just push down the whole batch of updates to the worker since the documents live in a single shard and process the batch there, going from 1 call per each update to 1 call for all updates. With this improvement, on my local box with a collection of 2 million documents of 1kb and a batch update of 500 documents I see the following improvements: Before: ~520ms After: ~220ms That's roughly 50% improvement. The feature is disabled behind a GUC so that we can test it and slowly enable it since it changes a critical code path. Next, we could probably reduce the 270ms further more for unsharded updates where the filter query operates on the _id node, that will be investigated and done on a separate PR. Also, sharded and single node queries should benefit from this change a bit (around a 10-15%) because we're removing calculating the update of the document from the SELECT FOR UPDATE query in SelectUpdateCandidate and instead, just select the candidate and perform the update in code directly.