3 ms·
> breadth-first loading. The ideal solution requires us to load the data in a breadth-first approach, but unfortunately, this is harder to write because it does
by bfung 4y ago
> breadth-first loading. The ideal solution requires us to load the data in a breadth-first approach, but unfortunately, this is harder to write because it does not compose well.
The author finds the simplest and efficient solution, but continues to over engineer for blog content :P
“Composing” is overrated in this case.
- ananthakumaran 4y agoThis is a contrived example, probably not a real-world use case. The kind of issues I am dealing at work is much more complicated, usually involves more than 3 or 4 tables, serializers are referred by multiple other serializers etc. There is usually business logic involved as well in the query construction. I understand things can be improved, but it's not as simple as writing few queries by hand. ActiveRecord/ActiveModelSerializer provides good composability, but fails to handle N + 1 queries optimally, which is what I am trying to explain.