I want to know how many queries being executed in a particular database for a past 5 min(given time). I used a table performance_schema.events_statements_summary_by_digest to calculate the count, but the issue in that is for each query it has the sum_count(total number of time the query have been executed) i.e if a query is executed once in past 5 min, but executed 100 times before 5 mins, the count is returned as 101, i want only execution count for the past 5 min
the query i used :
SELECT IFNULL(SUM(COUNT_STAR),0) AS count,
IFNULL(SUM(SUM_TIMER_WAIT)/1000000000,0) AS avg_waittime,
IFNULL(SUM(SUM_LOCK_TIME)/1000000000,0) AS avg_locktime,
IFNULL(SUM(SUM_ERRORS),0) AS avg_error,
IFNULL(SUM(SUM_WARNINGS),0) AS avg_warning,
IFNULL(SUM(SUM_ROWS_AFFECTED),0) AS avg_rows_affected,
IFNULL(SUM(SUM_ROWS_SENT),0) AS avg_rows_sent,
IFNULL(SUM(SUM_CREATED_TMP_DISK_TABLES),0) AS avg_tmp_disk_tb_crt,
IFNULL(SUM(SUM_CREATED_TMP_TABLES),0) AS avg_tmp_tb_crt,
IFNULL(SUM(SUM_ERRORS),0) as sum_error,
IFNULL(SUM(SUM_WARNINGS),0) as sum_warning
FROM performance_schema.events_statements_summary_by_digest
WHERE SCHEMA_NAME='test_db'
AND LAST_SEEN > DATE_SUB(NOW(), INTERVAL 300 SECOND)
please help me to find this