统计最近N秒内的QPS值(包括每秒select,insert等值)
mysql> select variable_name,sum(per_sec) as qps from (select straight_join lower(gs0.variable_name) as variable_name, (gs1.variable_value - gs0.variable_value)/5 as per_sec from ( select variable_name ,variable_value from information_schema.global_status where variable_name in ('com_select','com_update','com_insert','com_replace','com_delete') union all select '',sleep(5) from dual ) as gs0 join information_schema.global_status gs1 using (variable_name)) t group by variable_name with rollup;
+---------------+---------+
| variable_name | qps |
+---------------+---------+
| com_delete | 0 |
| com_insert | 2.2 |
| com_replace | 0 |
| com_select | 11524.8 |
| com_update | 3 |
| NULL