For most of the applications I'm working on, I turn on query profiling output, which can be easily turned on in the development environment. This displays SQL, runtime, stack trace, and a link to output the explanation. It also highlights queries longer than 1 second.
Although you probably don't need something complicated, you can get a pretty good idea of ββthe query execution time by writing a function in PHP that completes the query and stores debugging information in the session (or just displays it). For instance:
function run_query($sql, $debug=false, $output=false) { $start = microtime(true); $q = mysql_query($sql); $time = microtime(true) - $start; if($debug) { $debug = "$sql<br/>$time<br/><br/>"; if($output) { print $debug; } else { $_SESSION['sql_debug'] .= $debug; } } return $q; }
This is just some gross idea. You can customize it as you wish.
Hope this helps -
source share