How to profile MySQL during a period of time I want to know during the execution of sysbench --time=100 ..., the bottleneck (function) of MySQL. So I want to profile MySQL when executing sysbench --time=100 ....
I know by set profiling = 1;, I can get such profile for a specific query, but not for a period of time (100 seconds). What can I do?
Thanks.
In my experience, PROFILE always said that 99% of the time was spent in some &quot;useless&quot;  category, such as &quot;sending data&quot;.  Such categories 'never' translated into anything actionable.  PROFILE is being deprecated -- good riddance.
EXPLAIN SELECT ... and EXPLAIN FORMAT=JSON ... have some use.  So does the &quot;optimizer trace&quot;.
Use the slowlog: mysql.rjweb.org/doc.php/mysql_analysis#slow_queries_and_slowlog And you can do that on a live system.
Another technique for looking into what is going on is with the &quot;Handler&quot; counts.  This works even when a table is [currently] so small that timings are not very useful.  Details:  http://mysql.rjweb.org/doc.php/index_cookbook_mysql#handler_counts