Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear MySQL query profiles

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.

like image 385
Ray Avatar asked Jan 20 '14 17:01

Ray


People also ask

What is MySQL profiling?

Query Profiler, built into dbForge Studio for MySQL, is the best query optimization tool to tune MySQL queries and investigate query performance issues in an efficient and fast way. It helps build up a picture of how the queries are run to access data and what operations impact your application.

What is query profiling?

Query Profiler generates profiling results that can help you analyze and maximize query performance in SQL Server databases. The tool allows you to collect detailed statistics about executed queries, reveal and force slow queries and troubleshoot performance issues.


2 Answers

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

like image 96
Chris Blackwell Avatar answered Sep 22 '22 14:09

Chris Blackwell


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

like image 38
moritz Avatar answered Sep 18 '22 14:09

moritz