Sometimes when importing data into MySQL using the following method it can take a very long time, especially if the file is very large in size:

shell> mysql < importfile.sql

I have therefore developed a tiny patch to the mysql client which uses stderr to show the progress of the import in number of lines every 1000 lines of import.  This isn't quite a progress bar but should give you an indication of how long the import will take.

The patch for MySQL 5.1.30 is available here.

Comments:

For large imports, I will often use the 'bar' program from:

http://www.theiling.de/projects/bar.html

You can use it like cat, but it provides an ASCII progress bar. Normally, it is used as:

bar importfile.sql | mysql

Of course, it would be nice to not have to install an additional program from a third part to get this functionality.

Posted by Harrison Fisk on December 10, 2008 at 03:13 PM GMT #

An excellent utility. My original plan for this patch was some kind of progress bar but I am not quite sure how to figure out how to capture the file and work out the size of the file correctly (answers on a postcard). You could be using a streaming device as an input for example.

I suppose it could be possible to have the file as a parameter instead, that way it would be easy to calculate. In any case 'bar' is an excellent workaround for this.

When I do a similar patch mysqldump as well (over the next few days) it will be a lot easier to add some kind of progress bar to it.

Posted by LinuxJedi on December 10, 2008 at 04:57 PM GMT #

Post a Comment:
  • HTML Syntax: NOT allowed

This blog copyright 2009 by LinuxJedi