Skip to content

Instantly share code, notes, and snippets.

@jperkins
Forked from jnewland/gist:442388
Created June 18, 2010 13:43
Show Gist options
  • Save jperkins/443644 to your computer and use it in GitHub Desktop.
Save jperkins/443644 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')*1.0 / File.size('moves.ibd')*1.0)
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}"
puts "estimated duration: #{duration/60} minutes (#{duration/60/60} hours)"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment