RTK Query: Performance issues with upsertQueryData
, makes UI hang
#4643
-
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
Hi! Funny you should ask this :) I actually literally have a draft PR up that adds a new util for doing batched upserts with much better perf: Could you try out the CodeSandbox CI build from that PR and see how that affects the performance? And yes, the relatively slow perf you're seeing is in a sense "expected". |
Beta Was this translation helpful? Give feedback.
Hi! Funny you should ask this :) I actually literally have a draft PR up that adds a new util for doing batched upserts with much better perf:
Could you try out the CodeSandbox CI build from that PR and see how that affects the performance?
And yes, the relatively slow perf you're seeing is in a sense "expected".
upsertQueryData
uses the normal async thunk flow, which involves dispatching a separatepending
andfulfilled
action for each item. That also means2 * N
calls to the Redux store root reducer, all the Immer immutable update logic, and calling all the store subscribers afterwards.