Skip to content

Instantly share code, notes, and snippets.

@davidreuss
Created May 25, 2011 09:17
Show Gist options
  • Save davidreuss/990652 to your computer and use it in GitHub Desktop.
Save davidreuss/990652 to your computer and use it in GitHub Desktop.
mysql queries per. second estimated
SELECT MAX( -- use MAX to force aggregation
IF(variable_name='Questions' -- no. of queries sent to server
, CAST(variable_value AS unsigned) -- make integer value
, 0 -- ignore if not 'Questions'
)
)
/ -- divide by
MAX( -- use MAX to force aggregation
IF(variable_name='Uptime' -- no. of seconds the server is up
, CAST(variable_value AS unsigned) -- make integer value
, 0 -- ignore if not 'Uptime'
)
) AS queries_per_second
FROM information_schema.GLOBAL_STATUS
WHERE variable_name in ('Questions', 'Uptime');
@davidreuss
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment