Question

After turning on profiling in MySQL

  SET profiling=1;

I can run like a query like SELECT NOW(); and see profile results with it's execution time using:

  SHOW PROFILES;

However, I can't figure how to clear out the profile listing. Anyone know the statement to delete old profile data? SET profiling=0; just disables logging of new data and doesn't remove old stats.

Was it helpful?

Solution

To remove previous query profiles set @@profiling_history_size=0. The following snippet clears the profiles, sets the history to its maximum size and enables profiling

SET @@profiling = 0;
SET @@profiling_history_size = 0;
SET @@profiling_history_size = 100; 
SET @@profiling = 1;

Tested on 5.6.17

OTHER TIPS

For completeness' sake: Closing the current connection to the server and reconnecting resets the profiling counts.

Profiling information is stored under information_schema.profiling temporary table as referenced in http://dev.mysql.com/doc/refman/5.0/en/profiling-table.html

Under a database user that has the required access level you can truncate the information stored there, if the engine allows it;

TRUNCATE TABLE information_schema.PROFILING;

If not you can restart the MySQL server, as information_schema is stored solely in memory, profiling information is not preserved after service restart.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top