Created
September 21, 2009 16:29
-
-
Save slashdotdash/190361 to your computer and use it in GitHub Desktop.
MySQL, Alter Table, and How to Observe Progress
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
#!/bin/bash | |
(while(true); do \ | |
(mysql -e 'show innodb status \G' | grep undo\ log\ entries ; sleep 1 ; \ | |
mysql -e 'show innodb status \G' | grep undo\ log\ entries ) | \ | |
egrep '[0-9][0-9][0-9][0-9]' |awk '{print $10;}' ; done ) | \ | |
perl -e '$t = ROWS_IN_TABLE; while(1) { \ | |
$n ++; $nn; $a = <>; $b = <>; $nn += ($b-$a); \ | |
printf "Rate: %d, avg: %d, %0.3f%% complete, done in %d sec\n", \ | |
$b-$a, $nn/$n, ($b/$t)*100, ($t-$b)/($nn/$n); }'; | |
# http://gabrielcain.com/blog/2009/08/05/mysql-alter-table-and-how-to-observe-progress/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(Yeah I know, that this thing is 9 years old, but Google still shows this quite high in the search results :D )
The above mentioned shell script is outdated and does not return result, because with newer mysql versions:
was changed to:
and even with this thing sorted out, when I try to run the above mentioned script I get:
error (sorry, but my shell-fu is too weak to fix that :( )
BUT I've managed to achieve a very similar result using instructions in the article, that I link to here.