Is there a way to get the execution time of the last executed query in mysql?
Now, go to the Scalyr dashboard menu and select MySQL. You will be able to see the log details of your MySQL, which includes the query time. This is a very simple and easy way to measure query time for a large number of MySQL queries.
Using Client StatisticsGo to Menu >> Query >> Select Include client Statistics. Execute your query. In the results panel, you can see a new tab Client Statistics. Go to the Client Statistics tab to see the execution time.
SET GLOBAL MAX_EXECUTION_TIME=1000; Then any SELECT statement run against this MySQL instance will be aborted if it takes more than 1 second to complete. The default for the GLOBAL variable is 0, which means that there is no global time limit.
Duration shows the time needed to execute the query and fetch is the time needed to read the result set (retrieve the data)
mysql has a builtin profiler. You can enable profiling by issuing set profiling=1;
and use show profiles;
to get execution times.
if using PHP .. you can use microtime() before the query and after the query to figure out how long it took for the query to execute.
$sql_query='SELECT * FROM table'; $msc=microtime(true); $mysql_query($sql_query); $msc=microtime(true)-$msc; echo $msc.' seconds'; // in seconds echo ($msc*1000).' milliseconds'; // in millseconds
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With