Skip to content

Instantly share code, notes, and snippets.

@xaprb

xaprb/mext.sql Secret

Created December 14, 2013 20:24
Show Gist options
  • Save xaprb/2ce5e3f1f4272d0c6e48 to your computer and use it in GitHub Desktop.
Save xaprb/2ce5e3f1f4272d0c6e48 to your computer and use it in GitHub Desktop.
Formats SHOW STATUS
SELECT STRAIGHT_JOIN
LOWER(gs0.VARIABLE_NAME) AS variable_name,
gs0.VARIABLE_VALUE AS value_0,
gs1.VARIABLE_VALUE AS value_1,
(gs1.VARIABLE_VALUE - gs0.VARIABLE_VALUE) AS diff,
(gs1.VARIABLE_VALUE - gs0.VARIABLE_VALUE) / 10 AS per_sec,
(gs1.VARIABLE_VALUE - gs0.VARIABLE_VALUE) * 60 / 10 AS per_min
FROM (
SELECT VARIABLE_NAME, VARIABLE_VALUE
FROM INFORMATION_SCHEMA.GLOBAL_STATUS
UNION ALL
SELECT '', SLEEP(10) FROM DUAL
) AS gs0
JOIN INFORMATION_SCHEMA.GLOBAL_STATUS gs1 USING (VARIABLE_NAME)
WHERE gs1.VARIABLE_VALUE <> gs0.VARIABLE_VALUE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment