开发者

See activity while executing a MySQL query

I'm executing a MySQL query that takes a very long time to finish (specifically, I'm importing a CSV with about 21 million rows using LOAD DATA INFILE, which takes about 20 minutes). Is there something like a verbose mode that will allow 开发者_如何转开发me to watch the query as it executes?

I've tried launching MySQL at the command line with -vvv, but it doesn't seem to make a difference in this case beyond repeating my query to me.


Here is a weird suggestion

Example: Importing data into a table called mydb.mytable where datadir is /var/lib/mysql

Step 1) Find out how big the CSV file is in bytes

Step 2) In mysql, start the LOAD DATA INFILE command in one Linux session

Step 3) In Linux, cd /var/lib/mysql/mydb

Step 4) In Linux, watch -n 0.5 ls -l mytable.*

This will display every 0.5 seconds the size of the table.

If the table is MyISAM, this method will let you watch the mytable.MYD and mytable.MYI files grow

If the table is InnoDB with innodb_file_per_table activated, you watch mytable.ibd grow.

This method will not work under all of the following three(3) conditions:
1. If mydb.mytable is InnoDB
2. If mydb.mytable is stored in /var/lib/mysql/ibdata1
3. If innodb_file_per_table is disabled.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜