Measuring actual MySQL query time

MysqlOptimization

Mysql Problem Overview


How can I measure the execution time of a query without measuring the time it spends waiting for a lock release etc? My only idea was to continuously measure same query and record the fastest time.

Mysql Solutions


Solution 1 - Mysql

Start the profiler with

SET profiling = 1;

Then execute your Query.

With

SHOW PROFILES;

you see a list of queries the profiler has statistics for. And finally you choose which query to examine with

SHOW PROFILE FOR QUERY 1;

or whatever number your query has.

What you get is a list where exactly how much time was spent during the query.

More info in the manual.

Solution 2 - Mysql

The accepted Answer is becoming invalid...

SHOW PROFILE[S] are deprecated as of MySQL 5.6.7 and will be removed in a future MySQL release. Use the Performance Schema instead; see http://dev.mysql.com/doc/refman/5.6/en/performance-schema-query-profiling.html

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMikhailView Question on Stackoverflow
Solution 1 - MysqlfancyPantsView Answer on Stackoverflow
Solution 2 - MysqlRick JamesView Answer on Stackoverflow