How to record execution time of all Procedures in MySql

Posted on

Question :

I want to record execution time of all procedures in MySql.

For example, I have a database named test and it contains 25 procedures. When a procedure runs, I’d like each execution time to be recorded in a separate table.

Answer :

Plan A: Add timing code in each proc.

Plan B: Add timing code around the CALLs.

Plan C: Use the slowlog (with a low value in long_query_time) to capture the timings for individual calls; then use pt-query-digest to summarize the results.

long_query_time = 0 will flood the disk with the slowlog; be cautious. =0.5 will catch only queries (such as CALL) that take longer than half a second. If you are primarily looking for the “slowest”, this may be a better option. See:

Leave a Reply

Your email address will not be published. Required fields are marked *