This blog is part of our Rails 5.1 series.
Let’s take a project with hundreds of users.
When we call inspect on
we see an array of 10 users followed by
That means the output of
shows data only for
We can see that the query
executed in the process
is fetching all the records
even though the output doesn’t need all of them.
In Rails 5.1,
only the needed records are loaded
inspect is called on ActiveRecord::Relation.
We can see in the above case
that query executed has limit constraint
and hence only the required number of records are loaded.