Ask A Question

Notifications

You’re not receiving notifications from this thread.

Parallel ActiveRecord Queries with load_async in Rails 7 Discussion

Are there any downsides to using load_async on everything if we know for a fact that we’ll be using the data during the request? It seems like a no-brainer if we can keep db connections in check?

Reply

It depends on how many threads you can handle on your system. So I would imagine there is probably an upper limit. They addressed this in the PR https://github.com/rails/rails/pull/40037#discussion_r571920259

Basically, having it as default might lead to unintentional consequences. Whereas, using it for queries that are exceptionally long might be the best fit for it.

Reply

it looks like the async queries saved time on the front end ..... but didn't that cost get paid on the backend? I'm unclear where the savings comes from ? And, are these queries cached in some way such that ensuing requests that contain those same queries would absolutely be faster?

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,796+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.