Skip to content

RTK Query: Performance issues with upsertQueryData, makes UI hang #4643

Answered by markerikson
ceisele-r asked this question in Q&A
Discussion options

You must be logged in to vote

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 separate pending and fulfilled action for each item. That also means 2 * N calls to the Redux store root reducer, all the Immer immutable update logic, and calling all the store subscribers afterwards.

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@EskiMojo14
Comment options

@markerikson
Comment options

@ceisele-r
Comment options

@markerikson
Comment options

@ceisele-r
Comment options

Answer selected by ceisele-r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants