Mysql – How to know the progress when importing data into MySQL using LOAD DATA INFILE

MySQL

I have a 1 billion record stored in csv file. I'm using LOAD DATA INFILE to import the record to the table.

create table weibo_bind
(
    column1 bigint
        primary key,
    column2 bigint
);

And my csv file is column1,column2.

LOAD DATA INFILE '/path/to/demo.csv' IGNORE INTO TABLE weibo_bind FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' IGNORE 1 ROWS;

But how can I debug or how can I check the progress of importing? Because it takes a lot of time to import.

Or is there any way to speed up?

I'm using

mysql Ver 8.0.22, Innodb

Best Answer

Sort the incoming file by the PRIMARY KEY; this will speed up the LOAD. Don't have any secondary keys during the load.

There is no way (that I know of) to watch the progress in 8.0.

The .ibd file size is not a reliable indication -- you can't easily predict how big it will eventually be. Datatypes, data values, PK, other indexes, etc, impact the size.

Also, that file will grow in bursts.

Having just two BIGINTs (8 bytes each), the table might be about 40-60 bytes per row. The smaller range might be about right if the data is in PK order; the larger if not.

I hope the query does not timeout.

The process is probably I/O-bound, indicating that nothing you could do would speed it up.