How to see progress of .csv upload in MySQL

我们两清 提交于 2019-12-03 11:57:41

From http://www.stephenchu.com/2008/12/speed-up-your-mysql-data-load.html, you can use the SHOW INNODB STATUS IF your table is Innodb type, which you didn't happen to mention.

The page I linked to also has some good tuning suggestions to improve your overall performance with loading data in this manner.

On Linux you can print info about file descriptor (ls -l /proc//fd), and file position reader (cat /proc//fdinfo). So:

  1. Find mysqld pid (in this example: 1234):

    $ ps -ef | grep mysqld

    mysql 1234 1 0 feb12 ? 00:00:55 /usr/sbin/mysqld

  2. Find file descriptor number of your loaded file (in this example: 45):

    $ sudo ls -l /proc/1234/fd

    lr-x------ 1 root root 64 Feb 13 10:56 45 -> /var/lib/mysql/db/Loaded_file.txt

  3. Print info about that file descriptor and check number of bytes already read (in this example: 494927872):

    $ cat /proc/1234/fdinfo/45

    pos: 494927872

    flags: 0100000

You can compare this progress indicator (in bytes) to the actual file size being loaded.

Instead of step 1 and 2, you can also use 'lsof' command:

$ lsof /var/lib/mysql/db/Loaded_file.txt | grep mysql

COMMAND   PID     USER   FD   TYPE DEVICE SIZE/OFF    NODE NAME

mysqld    1234 youknowwho    45r   REG  252,0   190312 5505353 /var/lib/mysql/db/Loaded_file.txt
Brian Sanders

Couple of approaches here...

  1. set session transaction isolation level read uncommitted; Then count(*) will work
  2. select rows_read as 'Read', round((rows_read/{linecount})*100, 2) as 'Complete', round(time/60, 2) as 'Elapsed', round(time * 100 / round((rows_read/<line count>)*100, 2) / 60, 2) as 'ETA' from INFORMATION_SCHEMA.PROCESSLIST where id = <id>;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!