开发者

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 开发者_JS百科there any way??


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜