MySQL import using zcat log time script is complete

627 views Asked by At

We need to run a test import before doing things in our live environment but need to know how long the import takes.

The file 10Gb at Max compression, when uncompressed its around 170 Gb. In the past when we have run tests it has taken around 9 hours which is too long to sit in front of a PC and watch :-)

Is there a way to log how long the import takes / when it finished.

We are running this command to import the script: zcat /import_file.sql.gz | mysql -u 'root' -p database

If we were able to log a time to a file once the script is completed that would be perfect.

I am aware of "show table status;" but we are unsure what the last table is called so this kind of doesn't help.

Thanks in advance.

1

There are 1 answers

0
Luke Rayner On

I found the answer you can use the time command and then log the output to a file.

here is the command: { time zcat /import_file.sql.gz | mysql -u 'root' -p database ; } 2> time.txt

the 2> with store the output into the time.txt file. I hope this helps anyone with this issue.