How can i know the page from where slow query was hitting in MySQL in error log

107 views Asked by At

How can i know the page from where slow query was hitting in MySQL, like

"SELECT * FROM Users WHERE id=123"

Lets say this query was written on page user.php and on many other pages and this query caught in slow log

Now i need to know the exact page on which this was run from error log

1

There are 1 answers

3
Rick James On

Grep your source code for SELECT * FROM Users WHERE id=.

Change the PHP code to include a comment (/*...*/) in each SELECT to say where it came from. (If the slowlog strips comments, then add on AND 'page5'='page5' as a harmless, but useful, bit of info.)