c_minn
c_minn

Reputation: 1

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

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%';

Upvotes: -1

Views: 393

Answers (1)

Svein Terje Gaup
Svein Terje Gaup

Reputation: 1578

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

Upvotes: 0

Related Questions