简体   繁体   中英

How to calculate execution time of a stored procedure in MySQL?

If I have this script that creates and calls a procedure:

 SET profiling = 1;


 /*Create procedure */
DELIMITER ++
DROP PROCEDURE IF EXISTS newproc++

CREATE PROCEDURE newproc()
       BEGIN
DECLARE x  INT;
SET x = 1;

WHILE x < 500 DO  

   SELECT * FROM tableName
   WHERE survived = 1
   ORDER BY class ;

   SET x = x + 1;
END WHILE;

END
++   
DELIMITER ;

/*Call procedure */
CALL newproc();


SHOW PROFILES;

SHOW PROFILES displays the individual execution time of each of the 500 queries.

But how I can display the total execution time of all the queries combined(ei the execution time of the newproc() procedure)?

Event timings using the intervals YEAR, QUARTER, MONTH , and YEAR_MONTH are resolved in months; those using any other interval are resolved in seconds. There is no way to cause events scheduled to occur at the same second to execute in a given order. In addition—due to rounding, the nature of threaded applications, and the fact that a nonzero length of time is required to create events and to signal their execution—events may be delayed by as much as 1 or 2 seconds. However, the time shown in the INFORMATION_SCHEMA.EVENTS table's LAST_EXECUTED column or the mysql.event table's last_executed column is always accurate to within one second of the actual event execution time.

Refer this page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM