I am using a simple query in ActiveRecord which does something like this.
MyTable.find(:all, :conditions => {:start_date => format_time(params[:date]) })
I want to get the equivalent query that is executed in the background, perhaps using a puts statement or something similar to that. MySQL is my database.
You can see the SQL query that is executed by viewing the development log located in
log/development.log. Note that thescript/servercommand tails this log file by default.In Rails 3 you can append a
.to_sqlmethod call to the end of the finder to output the SQL.Alternatively, New Relic‘s free RPM Lite gem lets you see the SQL queries in developer mode as well as lots of other useful performance tuning information.