Skip to content

Instantly share code, notes, and snippets.

@eric
Forked from jnewland/gist:442388
Created June 17, 2010 17:37
Show Gist options
  • Save eric/442441 to your computer and use it in GitHub Desktop.
Save eric/442441 to your computer and use it in GitHub Desktop.
# 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