<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Simon,<div class=""><br class=""></div><div class="">Rewriting the eager load to match the access pattern did the trick – thank you!</div><div class=""><br class=""></div><div class="">It's obvious in hindsight... :)</div><div class=""><br class=""></div><div class="">Thanks again,</div><div class=""><br class=""></div><div class="">Andy</div><div class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 4 Aug 2020, at 12:28 pm, Simon Coffey <<a href="mailto:simon@urbanautomaton.com" class="">simon@urbanautomaton.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hey Andy,<div class=""><br class=""></div><div class="">I think the problem might be that eager loading is applied to specific associations, and the ones you're applying eager loading to aren't the ones that you're using to perform your reads.</div><div class=""><br class=""></div><div class="">Specifically, with `some_beta_scope.includes(gammas: :deltas)` you're eager loading the `Beta#gammas` and `Gamma#deltas` associations, but in your view you're using `Beta#deltas` and `Delta#gamma` to actually load the data. (<a href="http://screenshots.urbanautomaton.com/20200804-p79pj.png" class="">possibly-unhelpful illustration</a>)</div><div class=""><br class=""></div><div class="">You'd either need to rewrite the eager load to match your access pattern (`some_beta_scope.includes(deltas: :gamma)`, I <i class="">think</i>), or rewrite the loop to match the eager loading, e.g.</div><div class=""><br class=""></div><div class="">- @betas.each do |beta|<br class="">  = <a href="http://beta.name/" rel="noreferrer" target="_blank" class="">beta.name</a><br class="">  - beta.gammas.each do |gamma|</div><div class="">    - gamma.deltas.each do |delta|<br class="">      = <a href="http://delta.name/" rel="noreferrer" target="_blank" class="">delta.name</a><br class="">      = <a href="http://delta.gamma.name/" rel="noreferrer" target="_blank" class="">gamma.name</a><br class=""></div><div class=""><br class=""></div><div class="">Does that work?</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">Simon</div></div></div></blockquote></div><br class=""></div></body></html>