Skip to content

Instantly share code, notes, and snippets.

@victorpendleton
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save victorpendleton/9677bf91bd898fee66eb to your computer and use it in GitHub Desktop.
Save victorpendleton/9677bf91bd898fee66eb to your computer and use it in GitHub Desktop.
SQL used to calculate MySQL log size based on current usage and compare to actual size
SELECT variable_value into @start
from information_schema.global_status
where variable_name = 'innodb_lsn_current';
SELECT sleep(60);
SELECT variable_value into @end
from information_schema.global_status
where variable_name = 'innodb_lsn_current';
SELECT ROUND( ((@end-@start)/1024/1024)*60, 2) INTO @calculatedSize
FROM dual;
SELECT variable_value/1024/1024 INTO @currentSize
FROM information_schema.global_variables
WHERE variable_name = 'innodb_log_file_size';
SELECT @currentSize AS CurrentLogSize
, @calculatedSize AS CalcualtedLogSize
, ROUND( ((@calculatedSize - @currentSize)/@CurrentSize) * 100, 2) AS Delta
FROM dual;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment