Reputation: 5969
I've a slow query log from MySQL on one side and a big PHP application on the other side littered with mysql_query()
statements. I'm searching for a better solution to find the slow queries from the log in the PHP application code other than intelligently grep'ing the source code.
My idea is that it might be possible to enrich the SQL queries with some meta information i.e. the file name and the line number where the mysql_query()
is called. But I can't find anything targeting this issue.
Upvotes: 0
Views: 61
Reputation: 142296
Comments might be propagated to the SlowLog:
$sql = '/* ' . __FILE__ . ':' . __LINE__ . ' */ ' .
"SELECT ... ";
(This technique may be off, depending on what version of MySQL/MariaDB you are using.)
Upvotes: 0
Reputation: 1027
Please look at
http://php.net/manual/en/function.override-function.php
And comment from there:
rename_function('strlen', 'new_strlen');
override_function('strlen', '$string', 'return override_strlen($string);');
function override_strlen($string){
return new_strlen($string);
}
But I suggest you, to use any ORM, over your queries.
Upvotes: 1