shajin
shajin

Reputation: 3264

Corresponding MySQL queries of ActiveRecord queries

My client wants corresponding sql queries of all ActiveRecord query which using in the application.I can able to get most from the serVer log.But queries with relations are not showing in the server or development.log file.
for eg: Student.first returning SELECT * from students limit 1
but Student.first.school is not returning SELECT * from schools where id IN ......

Is there any way??

Upvotes: 0

Views: 169

Answers (1)

ypercubeᵀᴹ
ypercubeᵀᴹ

Reputation: 115530

Enabling the full query log (this requires restarting the MySQL deamon) will start writing all queries in that log file. It's usually not enabled because the file gets pretty big quickly. But you can have it on for a few hours so you can have all queries logged.

How to enable the General Query Log (or full query log): SO question: how-do-i-log-just-the-raw-queries-in-mysql or at: MySQL docs: General Query Log

You can select where the log is saved, either to a file or to a table:

MySQL docs: Selecting General Query and Slow Query Log Output Destinations

Upvotes: 1

Related Questions