Skip to content

Instantly share code, notes, and snippets.

@trak3r
Created March 8, 2013 20:43
Show Gist options
  • Save trak3r/5119697 to your computer and use it in GitHub Desktop.
Save trak3r/5119697 to your computer and use it in GitHub Desktop.
doing a big activerecord query with a lot of peripheral objects.
adding ".includes" (preloading) speeds it up dramatically by squashing all the
N+1's.
the page then renders fast and spits this out into the logs:
Completed 200 OK in 504ms (Views: 104.2ms | ActiveRecord: 86.0ms)
however, it is then *** 90 SECONDS *** until the page is actually sent down to
the browser (or curl; we've tested with both).
during which time the ruby process has the CPU pegged at 100%.
if we remove the ".includes" (preloading) it goes back to normal crappy
performance without the minute-and-half chasm of nothingness between page
render and browser delivery.
WTF does the preloading cause that after effect!?
Rails 3.2.12
Ruby 1.9.3 (p286 and p327 tested)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment