Skip to content

Instantly share code, notes, and snippets.

@gwillem
Created October 21, 2013 14:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gwillem/7084632 to your computer and use it in GitHub Desktop.
Save gwillem/7084632 to your computer and use it in GitHub Desktop.
Pure SQL to query for MySQL Query Cache Rate
-- run with:
-- boxes -f db | while read i; do echo -n "$i: "; cat qcache-ratio.sql | mysql -h $i | tail -1; done | sort -nk2
use INFORMATION_SCHEMA;
SELECT VARIABLE_VALUE FROM GLOBAL_STATUS WHERE VARIABLE_NAME = 'Qcache_hits' INTO @hits;
SELECT SUM(VARIABLE_VALUE) FROM GLOBAL_STATUS WHERE VARIABLE_NAME IN ('Qcache_hits','Com_select') into @total;
select round(@hits / @total * 100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment