We have a Rabl view that’s powered by a Rails action with nested children, in a structure like so:
:foo has many :bars
:bar has many :baz
Which means that our rabl view might look something like this:
collection @foo
attributes (#whatever)
child(:bar) {attributes :baz}
This works wonderfully, except for the fact that Rabl performs a new query to load each of the bar objects, as well as each of the baz objects (there are up to 7 baz objects). The query that generates the original collection takes less than 100ms to return, but the total rendering time takes upwards of 8 seconds, and includes about 30 additional queries per foo record. I’ve tried using the includes syntax to preload the associated rows so that Rabl wouldn’t need to reload them, but it seems to just ignore the information that’s sent along.
I’m looking for an idea as to how I can optimize this operation so that we can get the best possible performance out of this. I’m not quite sure what the right way to attack from here really is.
Thanks in advance.
Unfortunately, I couldn’t come up with an acceptable way to speed things up using Rabl, so I was forced to make this one endpoint build the response object by hand.