Last active
August 29, 2015 14:06
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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