I have been working on optimizing the performance of a Rails app by
rewriting the AR record methods into custom sql queries. What I did is
that the result from the query is not instantiated as an object, which
is supposed to be too time consuming.
Here are the performance difference between using default AR methods and
its custom equivalent. The number of requests per second was read from
the log file, it is not super accurate but gives a relative figure which
The first figure is the default AR method, the second one is the custom
In development mode:
find(:all): 15 req/s -> 30 req/s. Wow I get twice as much throughput.
In production mode:
find(:all): 80 req/s -> 60 req/s. Damn'it!
I don't understand why in production mode, my custom sql query yields
less performance than the AR methods.
What am I missing?