Kill N+1 Queries For Good with Strict Loading
Starting with Rails 6.1, we can set a strict_loading configuration option that, when true, will throw an error if your code attempts to lazy load any associations with out strictly including the association in the ActiveRecord query. A brief history on N+1 queries and Ruby on Rails Rails has a long history of scaling problems and a big cause of this is slow database performance of N+1 queries. Rails makes it super easy to get data from a database and magically have all of it at your finger tips.