N + 1 is better in this case by a mere implementation coincidence.
vemv
1

Hi vemv! Thanks for your comment!

Personally I wound’t call it a “mere implementation coincidence” 😅 I’m not sure if DHH first found it by accident or it was any coincidence, but when he represented the idea it was definitely a sorted thinking. And we examined and adapted that carefully and did see its power (and caveat in the contract).

Of course depends on the situation you could cache in the model layer but I think that’s beyond the scope of this post.

And I also truly agree there should be no excuse for N+1, either fix it or tame it with the intention in mind. But I also don’t expect or encourage developers referring to this post as an excuse to get away from dealing with N+1 either. If the strategy showed in the post can’t be adapted to the system, then really need to focus on killing those N+1. That’s my stance.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.