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?
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.
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?