Posts

Showing posts with the label Eager loading

Ruby on Rails: Understanding, Optimizing, and Mastering Database Queries with Preloading, Eager Loading, Includes, and Joins

Hi, This is  Shubham Mishra  from India,  this is the part of  Ruby on Rails  exploration journey.  In this post we will discuss about the ruby's some special concepts and I am sure you will get excited to make your hands dirty with those code, so why to wait let's get started... In this article we will explore best practices to avoid N+1 query issue in ruby on rails and also best practices to make database query optimised. And we also need to keep below stuffs in mind while doing the code review of our peer. Ruby on Rails offers a number of methods for preloading related items in order to get around the N+1 query problem. When the application does his N+1 database queries, the N+1 query problem arises. where N represents the total number of records found. Serious performance problems may result from this, especially when working with huge datasets. Using eager loading, which preloads related objects when the database is requested, is one way to deal wi...