This project is archived and is in readonly mode.

#3642 ✓committed
Comron Sattari

Quoting in ActiveRecord::Base is inefficient

Reported by Comron Sattari | December 31st, 2009 @ 04:27 PM

During performance testing I noticed queries with many bind variables that are fast on mysql are very slow through rails, I believe this is due to ActiveRecord::Base.connection being called at least once for each bind variable. The following patch is just a demo to show how I got the number of calls reduced by more than a factor of 10, which was about a 50% speed increase for my particular problem.

The column_aliases fix, although we didn't profile it, should help speed up ActiveRecord queries with many joined in columns.

Is the connection something that really needs to be looked up so often, and not just memoized for the entire request? Surely the connection isn't changing between bind variables. :)

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Referenced by

Pages