1
votes

Recently we've been noticing bad performance of our app, and using the blocked-at package found that Sequelize (v5.22) is blocking the node event loop on large queries.

The query in particular isn't complicated, just FooModel.findAll(someOptions), without any joins either. It's just that the result could be up to 100k rows.

Are there some known methods to improve performance, or at least ensure that the event loop won't be blocked?

1
Looks like you need to use pagination in order to get 100k records by using chunks of reasonable size. It's bad idea to get all at once because after getting them from DB Sequelize needs to turn them into objects that takes some time and occurs in the main thread. Another way is to use worker threads - Anatoly

1 Answers

0
votes

Further testing with blocked-at has shown that the trace it gives isn't always 100% accurate. It sometimes indicates the point at which control was returned to the event loop, instead of the task that caused the event loop to be blocked.

In my case, the issue wasn't FooModel.findAll, but some logic before that.