4

When I start mysqladmin, it prints out several statistics, including "Queries per second avg":

# mysqladmin --defaults-file=../mylogin.cnf status
Uptime: 4568115  Threads: 859  Questions: 3703806462  Slow queries: 19415  Opens: 10300505  Flush tables: 247  Open tables: 2000  Queries per second avg: 810.795

Can I retrieve this "Queries per second avg" value within an SQL query? We use MariaDB 10.1.x

1 Answer 1

5

For those running MariaDB and MySQL (If using 5.7, show_compatibility_56 enabled)

SELECT Q / T Queries_per_second_avg FROM
(SELECT variable_value Q FROM information_schema.global_status
WHERE variable_name = 'Questions') A,
(SELECT variable_value T FROM information_schema.global_status
WHERE variable_name = 'Uptime') B;

For those running MySQL 5.7, show_compatibility_56 disabled

SELECT Q / T Queries_per_second_avg FROM
(SELECT variable_value Q FROM performance_schema.global_status
WHERE variable_name = 'Questions') A,
(SELECT variable_value T FROM performance_schema.global_status
WHERE variable_name = 'Uptime') B;
2
  • 1
    'Questions' doesn't include statements executed within stored programs -- use 'Queries' instead if you want to include those. You can also use 'Com_select', 'Com_insert', 'Com_delete', 'Com_update' to get numbers for certain types of queries, though these values don't include query cache hits.
    – dbdemon
    Jun 27, 2018 at 15:12
  • 1
    @dbdemon You are right, I mentioned that 3 years ago : dba.stackexchange.com/questions/102265/… Jun 27, 2018 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.