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
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.
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.
mysql shows how many rows were returned and how long the query took to execute, which gives you a rough idea of server performance.
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.
The answer is to enable the mysql profiler and then check it after you run your queries.
mysql> set profiling=1;
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