Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql execution time

Tags:

Is there a way to get the execution time of the last executed query in mysql?

like image 267
mck89 Avatar asked Oct 27 '09 14:10

mck89


People also ask

How does MySQL calculate query execution time?

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.

How do you check query execution time?

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.

What is Max execution time in MySQL?

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.

What is Fetch time in MySQL?

Duration shows the time needed to execute the query and fetch is the time needed to read the result set (retrieve the data)


2 Answers

mysql has a builtin profiler. You can enable profiling by issuing set profiling=1; and use show profiles; to get execution times.

like image 59
soulmerge Avatar answered Oct 14 '22 04:10

soulmerge


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 
like image 26
Sabeen Malik Avatar answered Oct 14 '22 05:10

Sabeen Malik