how to count the number of times a statement has been executed in mysql?

358 Views Asked by At

I want to sort the results in a descending order of the total number of times each statement has been executed.

Statements executed:

SELECT CONVERT (argument USING utf8)
FROM mysql.general_log
WHERE argument LIKE '%SELECT%' 
OR argument LIKE '%INSERT%' 
OR argument LIKE '%DELETE%' 
OR argument LIKE '%UPDATE%';
1

There are 1 best solutions below

0
Svein Terje Gaup On

Try

SELECT argument, count(*) FROM mysql.general_log WHERE argument LIKE '%SELECT%' OR argument LIKE '%INSERT%' OR argument LIKE '%DELETE%' OR argument LIKE '%UPDATE%' GROUP BY argument ORDER BY count(*) desc