Deriving join SQL incredibly slow on Rails 3

I was trying to work out why a page on my site was so slow. The
queries themselves seemed to be executing pretty quickly so I tried
playing around to see if Rails was causing the overhead.

I changed the line:
      records = Record.order(:col).joins(:table1)
      records = Record.order(:col).joins('INNER JOIN "table1" ON
"table1"."table2_id" = "table2"."id"')

...and this shaved 100s of ms off the page render time.

Can anyone else try this and confirm it?


There are some performance issues with arel (Active Relations) 1.0.x
(which is used by Rails 3.0.1). The 2.0.1 version is supposed to fix
these issues.

I believe that the next version of Rails 3 will use arel 2.0.x.