3 ms·
N+1 is because lazy loading is by default in ActiveRecord. Because it doesn't know anything about your object graph and what associations are needed, so it jus
by aantix 6y ago
N+1 is because lazy loading is by default in ActiveRecord.
Because it doesn't know anything about your object graph and what associations are needed, so it just loads data as it's encountered. That's a reasonable default.
You add includes as you know more about your data and what associations are needed in specific contexts. Eager loading is an optimization, not a prerequisite.