After profiling a call, I saw that more than half of the time
was spent in a single has_one sideload. The existing code has a couple
of cases of nested loops which were at the root of this. Replacing the
inner loops with Hash lookups caused my request time to go from >3.5s to
~1s (at which point, a lot of that is dependent on latency from upstream
resources and Rails itself).
After profiling a call, I saw that more than half of the time was spent in a single
has_one
sideload. The existing code has a couple of cases of nested loops which were at the root of this. Replacing the inner loops with Hash lookups caused my request time to go from >3.5s to ~1s (at which point, a lot of that is dependent on latency from upstream resources and Rails itself).