I have an application written in Ruby using Rails 2.3. We use ActiveRecord.
Sometimes ActiveRecord generates quite terribly inefficient SQL. We can determine that SQL is problematic using slow query logs and using a new relic . However, it is very difficult to determine the line of code in our software that created the problematic SQL. This is usually a query created using associations and named_scopes.
I would really like to somehow mark SQL in our log files with the file name and line of our code that generated it (and not the ActiveRecord line that executed the query).
Information should be accessible through an array of callers. I don’t want to unload the whole array, I just want the file name and line of our code to be most directly responsible. Is there a stone that is already doing this? If not, any suggestions?
source
share