Re:Ban 1+N in Django
by nickjj on Tuesday March 28, 2023 @07:20AM
(#35338879)
> zero if cache is hot (but 20 cache queries)
Rails lets you fetch_multi which means it would be 1 cache query if you used this feature.
> It is only a win if DB is the bottleneck
View rendering is pretty slow in Rails, rendering a view ends up being a real bottleneck. That's partly why caching that at the view layer is beneficial.
If Rails were able to cache templates as well as other frameworks then I would agree that in a lot of cases you wouldn't need to worry about it and could preload most things.
Rails lets you fetch_multi which means it would be 1 cache query if you used this feature.
> It is only a win if DB is the bottleneck
View rendering is pretty slow in Rails, rendering a view ends up being a real bottleneck. That's partly why caching that at the view layer is beneficial.
If Rails were able to cache templates as well as other frameworks then I would agree that in a lot of cases you wouldn't need to worry about it and could preload most things.