Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql query execution time - can i get this in milliseconds? [duplicate]

Possible Duplicate:
how to get load time in milliseconds or microseconds in mysql

I'm comparing a few different approaches to getting some data in mysql, directly at the console, using the SQL_NO_CACHE option to make sure mysql keeps running the full query every time. Mysql gives me the execution time back in seconds, to two decimal places. I'd really like to get the result back in milliseconds (ideally to one or two decimal places), to get a better idea of improvements (or lack of). Is there an option i can set in mysql to achieve this?

thanks, max

like image 211
Max Williams Avatar asked May 13 '10 09:05

Max Williams


People also ask

How does MySQL calculate query execution time?

Once executed, you can check the query execution time using the below query: show profiles; You will be able to see the duration of query execution in seconds. These ways are fine when you want to measure the query time for one or a few queries.

How can increase MySQL query execution time?

SET SESSION MAX_EXECUTION_TIME=2000; Then any SELECT statements run in this particular session are aborted if they take more than 2 seconds to complete. Finally, the maximum execution time can also be set for a specific SELECT statement using the MAX_EXECUTION_TIME hint directly in the query.

Which shows how many rows were returned and how long the query took to execute?

mysql shows how many rows were returned and how long the query took to execute, which gives you a rough idea of server performance.

Which query will take more time for execution?

There are a number of things that may cause a query to take longer time to execute: Inefficient query – Use non-indexed columns while lookup or joining, thus MySQL takes longer time to match the condition. Table lock – The table is locked, by global lock or explicit table lock when the query is trying to access it.


1 Answers

The answer is to enable the mysql profiler and then check it after you run your queries.

mysql> set profiling=1;
like image 115
Xeoncross Avatar answered Oct 05 '22 16:10

Xeoncross