Rusty Razor Blade
MySQL ALTER table Progress Bar?
Altering a big table sucks, and to make it worse you have no idea what’s happening or how long it will take. I’d like a progress bar, or some status output, or something that gives me the feeling like my server didn’t die.
6 Responses to MySQL ALTER table Progress Bar?
Leave a Reply Cancel reply
Recent Comments
- Anil on MySQL Triggers Tutorial
- Ashish on MySQL Triggers Tutorial
- David on iCal Agenda
- jon on IP address geolocation SQL database
- pim on IP address geolocation SQL database
- jnns on Redis Wildcard Delete
- K.C. Murphy on iCal Agenda
- BA on Experts Exchange should be removed from Google search results
- Andrew on Executing multiple curl requests in parallel with PHP and curl_multi_exec
- Stu on Executing multiple curl requests in parallel with PHP and curl_multi_exec
Recent Posts
- New Project: Jester
- Open New Terminal Tip
- Installing MySQLdb on MacOS Lion
- Headless VM Server Using Ubuntu 11.10
- Get rid of Facebook’s Awful Ticker
- Api Tester now hosted on Github
- Trac .11 jQuery bug
- Multiple Filetypes in Vim
- Git Tip: Setting Up Your Remote Server
- Install issue pymongo on OSX (setuptools out of date)
Categories
- amazon (1)
- answerbag (6)
- apache (9)
- apple (8)
- awk (2)
- bbedit (2)
- c++ (3)
- chrome (2)
- cluster (1)
- cocoa (1)
- collective intelligence (1)
- curl (3)
- db2 (1)
- demand media (1)
- ebay (1)
- eclipse (4)
- erlang (13)
- facebook (1)
- fortran (1)
- gen_server (1)
- git (5)
- google (4)
- haddad (1)
- hdf5 (1)
- html (1)
- innodb (1)
- itunes (1)
- java (2)
- jester (1)
- kvm (1)
- launchbar (1)
- leex (1)
- letsgetnuts.com (1)
- libvirt (1)
- links (6)
- linux (27)
- lucene (1)
- mac (16)
- memcached (1)
- misconception (1)
- mobile (1)
- mono (1)
- mssql (1)
- munin (1)
- mysql (31)
- numpy (1)
- oracle (1)
- php (23)
- puppet (4)
- pyparsing (1)
- pytables (1)
- python (11)
- q&a (1)
- quicksilver (1)
- rant (6)
- readynas (1)
- redis (2)
- regex (1)
- replication (1)
- search (1)
- shitty code (1)
- solr (3)
- spaces (1)
- sshfs (1)
- stored procedure (1)
- svn (5)
- textmate (2)
- tips (22)
- trac (1)
- tutorial (4)
- ubuntu (3)
- Uncategorized (4)
- unix (1)
- vim (3)
- virtual box (6)
- vmware (1)
- weird (3)
- wikipedia (1)
- windows (1)
- xcode (1)








If you are using InnoDB, and innodb_file_per_table, the alter creates a temp table, and then drops the original table and renames the temp table. While the alter is running, you can compare the size of the temp table’s file (in your data directory) with the size of the original table’s file, to get a rough idea of the progress.
It’s only a rough gauge of progress because fragmentation, etc. will make the original table’s file bigger than the temp table will be. The temp table file will probably not grow to the same size as the original table’s file, before it finishes.
Welcome to the club
For now, try something like (if innodb_file_per_table is enabled):
while true; do ls -lh /path/to/table.ibd; sleep 60; done
Re: Frank. Or you can try a less hacky and more proper way
‘watch -d -n 60 ls -lh /path/to/table.ibd’
Reference: http://beerpla.net/2007/08/04/watch-a-useful-linux-command-you-may-have-never-heard-of/
P.S. Online alter table is planned for 2009, as far as I remember from the conference. That will be a godsend.
Instead of ‘while true … etc’ you can also do:
watch ls -lh /path/to/table*
For more accurate info check out:
http://www.stillhq.com/mysql/000011.html
and
http://jcole.us/blog/archives/2007/02/08/progress-in-mysql-process-list/
Jeremy’s solution looks really nice
Would rock if that could be incorporated into MySQL. Would be even nicer if this could be done for other (non-ALTER) queries, one can dream, right?
yup…. Jeremy’s patch is more than a year old. MySQL has been sitting on their collective asses and not accepting external patches.
So much for the open source process….
Instead of making ‘alter table’ query you can create new one with all changes you want to do and type:
mysqldump all-usual-arguments | pv | mysql
pv is very useful tool to monitor pipes (http://www.ivarch.com/programs/pv.shtml)