Created
June 17, 2010 16:50
-
-
Save jnewland/442388 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 | |
begin | |
sleep(interval) | |
new_percentage = (File.size('#sql-137f_5dee5a6.ibd')*1.0 / File.size('users.ibd')*1.0) | |
change = new_percentage - percentage | |
intervals = (1.0-percentage)/change | |
duration = intervals*interval | |
eta = Time.now + duration | |
percentage = new_percentage | |
puts "percent done: #{percentage}" | |
puts "eta: #{eta}" | |
puts "estimated duration: #{duration/60} minutes (#{duration/60/60} hours)" | |
rescue RangeError | |
retry | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment