Asynchronous querying reduces the query time significantly as opposed to running multiple queries serially. This may not be a big issue in small applications that handle a small amount of data, however, as the database grows in size the response time for these queries also grows.
Before
1
2
@studios = Studio.all
@artists = Artist.order(published_at: :desc)
After
Rails 7 introduces the load_async
method that schedules queries to be performed asynchronously from a thread pool. For controllers that require to perform multiple independent queries, this method works great.
1
2
@studios = Studio.all.load_async
@artists = Artist.order(published_at: :desc).load_async
The above queries are performed in a thread pool, while the rest of the work is still done on the main thread.
For more changes and discussions on the change above, refer here