June 2024
Intermediate to advanced
456 pages
11h 34m
English
Rails 7 supports Asynchronous Query Loading[133] with the .load_async method. When running queries asynchronously, they use a new thread of execution, which grabs its own database connection. While this runs the query in the background, keep an eye on how many database connections are being used.
The post, “Running Queries in Parallel with Rails 7 and load_async,”[134] shows a nice example of where this can help. The post shows a number of queries in a Rails controller without .load_async, showing multiple database fetches. Each fetch executes serially, meaning one by one.
Looking at the same example, but using .load_async(), the second query right after the first query is not blocked on starting. Since ...
Read now
Unlock full access