-
-
Save eric/442441 to your computer and use it in GitHub Desktop.
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
# estimate the duration of an ALTER TABLE statement in mysql | |
# this code estimates the worst case, as most of the time, an ALTER will result in a table that is smaller than the original | |
percentage = 0 | |
interval = 10 | |
while(true) do | |
sleep(interval) | |
new_percentage = (File.size('#sql-5316_1a.ibd').to_f / File.size('moves.ibd').to_f) | |
change = new_percentage - percentage | |
intervals = 1.0/change | |
duration = intervals*interval | |
eta = Time.now + duration | |
percentage = new_percentage | |
puts "percent done: #{percentage}" | |
puts "eta: #{eta}" | |
hours, minutes = (duration / 60).divmod(60) | |
puts "estimated duration: %d:%02d" % [ hours, minutes ] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment