<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">This is great, many thanks everyone, much appreciated.<br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">And sorry for the slow reply. <br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">Duncan: re. swapping where and includes: .includes seems to prefer to generate IN () style of SQL queries even in that case.<br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">Frederick: we will try .eager_load and report back. <br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">Combining the datasets yourself without using the .includes: that's the issue, the responsebuilder does expect an activerecord object, so we'd need to refactor that - what I alluded to as plan B. Definitely a possible option. In fact, we'd create something else, as the responsebuilder is used everywhere.<br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">Julius: we'll definitely also add the .select, though it doesn't seem to make a major difference, as the table has few columns.<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">Pagination: that's definitely a good idea, something we may need to add anyway, also for usability.<br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">Ed: that is the problem indeed: creating the hashes implies re-writing the responsebuilder, which is our plan B if we can't figure out how to force the right queries into the right activerecord object. Agreed on pagination.<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">[Incidentally, we didn't expect clients to have quite that many feeds. What they say about real life messing up your plans etc.]<br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">Graham: thanks, and interesting that there seems to be some consensus around plan B.<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">Here are the gists of the <a href="https://gist.github.com/marcoi/c96fb66383147d096cf8" target="_blank">responsebuilder </a>and <a href="https://gist.github.com/marcoi/f0202a8710700e924db2" target="_blank">feedbuilder </a>(unnecessary stuff removed). As I was mentioning the former is used everywhere, the latter just here. We can build a bespoke builder.<br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">Also: we found this, which may be helpful for plan A<br><a href="http://blog.bigbinary.com/2013/07/01/preload-vs-eager-load-vs-joins-vs-includes.html" target="_blank">http://blog.bigbinary.com/2013/07/01/preload-vs-eager-load-vs-joins-vs-includes.html</a><br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">Thanks again everyone, really appreciated. Let me know if anything comes to mind, either way we'll report back once/if we get somewhere.<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br><br><br></div><br><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 14 December 2015 at 14:50, Graham Ashton <span dir="ltr"><<a href="mailto:graham@effectif.com" target="_blank">graham@effectif.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Mon, 14 Dec 2015, at 02:23 PM, Ed Saunders wrote:<br>
><br>
> I don't think the order of the "includes" or "where" will make a difference<br>
> though.<br>
<br>
</span>Agreed.<br>
<span class=""><br>
> Presumably either the FeedBuilder or ResponseBuilder is going to<br>
> call into the FeedDetail's associations which will make that difficult.<br>
> Without seeing those classes I'm not sure what else to suggest other than a<br>
</span>> potential rewrite…<br>
<br>
This is what I was going to suggest, but I think we’d need to see what `ResponseBuilder` does to give you any actionable advice.<br>
<br>
My gut feeling is that if I was in your shoes I’d replace `ResponseBuilder` with templates (e.g. jbuilder), and pass the results of the three fast (and simple) queries to the templates via the render call. I’m not sure what the forces are on `ResponseBuilder` (e.g. how often is it used, and what else might it interact with?) though, so I wouldn’t call it a solid suggestion just yet…<br>
<br>
Could you share `ResponseBuilder` and `FeedBuilder` in a gist?<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Graham Ashton (Founder, Agile Planner)<br>
<a href="https://www.agileplannerapp.com" rel="noreferrer" target="_blank">https://www.agileplannerapp.com</a> | @grahamashton | @agileplanner<br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
Chat mailing list<br>
<a href="mailto:Chat@lists.lrug.org">Chat@lists.lrug.org</a><br>
Archives: <a href="http://lists.lrug.org/pipermail/chat-lrug.org" rel="noreferrer" target="_blank">http://lists.lrug.org/pipermail/chat-lrug.org</a><br>
Manage your subscription: <a href="http://lists.lrug.org/options.cgi/chat-lrug.org" rel="noreferrer" target="_blank">http://lists.lrug.org/options.cgi/chat-lrug.org</a><br>
List info: <a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" rel="noreferrer" target="_blank">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a><br>
</div></div></blockquote></div><br></div>