3 ms·
The question was regarding N+1. If you're not careful with ActiveRecord, you get that. With Ecto, it's impossible. Ecto has its own drawbacks, but its strong s
by dmpk2k 6y ago
The question was regarding N+1. If you're not careful with ActiveRecord, you get that. With Ecto, it's impossible.
Ecto has its own drawbacks, but its strong suit is predictability.
- aantix 6y agoN+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.