Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL stuck on "Repair by Sorting" (ENABLE KEYS)

Tags:

mysql

I have a script that updates localhost, then dumps the updated results to remotehost:

mysqldump --skip-tz-utc --no-create-info --insert-ignore --host=localhost -u u -ppass db table --where=\"timeStamp > FROM_UNIXTIME( $time )\" | mysql -h remote -u u -ppass db

With 20 records, the update to localhost is very quick (a few seconds) but the dump to remotehost is taking over 4 minutes...when I look at mysql workbench, it says the state of remote host is "Repair by Sorting" and the Info column is "/*!40000 ALTER TABLE 'table' ENABLE KEYS */".

What does this message mean (and why is it taking so long to dump to remotehost with so few records)?

Thanks!

like image 580
user_78361084 Avatar asked Feb 15 '11 02:02

user_78361084


1 Answers

mysqldump is disabling indexes, inserting the records, and re-enabling the indexes. This means it affects the entire table, including the many more records I expect are there based on the time.

Add --skip-disable-keys to the arguments for mysqldump and that should stop happening.

like image 109
Jeff Ferland Avatar answered Nov 02 '22 22:11

Jeff Ferland