I have a runQuery() function that logs out any executed query to a text file during development and testing and then logs queries that take longer than my pain threshold to execute in production so I can see the bad queries and work on them.
I use runQuery instead of the php mysql functions. The php mysql functions are run inside the runQuery() function and inside that function I also set the vars to do the execution timing, etc.