You need to look at myisam_max_sort_file_size and myisam_sort_buffer_size settings
If the sum of all keys is less than myisam_max_sort_file_size, the sorting will in the worst case fall into the MyISAM table, which is good.
Otherwise, it will return to the key cache. This means loading the necessary .MYI index pages into keycache and moving those index pages in memory. Nobody wants this !!!!
In your current setting, 2G is specified for this variable.
Look at the built keys. Add them. If the sum of all key sizes exceeds 2G, keycache is complete! You will need to increase this value. You can increase this value for a session to 4G with
SET myisam_max_sort_file_size = 1024 * 1024 * 1024 * 4; SET myisam_sort_buffer_size = 1024 * 1024 * 1024 * 4;
or you can set the number directly as follows:
SET myisam_max_sort_file_size = 4294967296; SET myisam_sort_buffer_size = 4294967296;
before executing ENABLE KEYS;
If you're just interested in backing up data, why index it? Try using the ARCHIVE storage engine. It has no indexing. Follow these steps:
CREATE TABLE mytable_backup LIKE mytable; ALTER TABLE mytable_backup ENGINE=ARCHIVE; INSERT INTO mytable_backup SELECT * FROM mytable;
I also noticed that you are using Amazon EC2. I have never been to EC2 before. Run this command:
SHOW ENGINES; +------------+---------+----------------------------------------------------------------+--------------+------+------------+ | Engine | Support | Comment | Transactions | XA | Savepoints | +------------+---------+----------------------------------------------------------------+--------------+------+------------+ | InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES | YES | YES | | MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO | | BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO | | CSV | YES | CSV storage engine | NO | NO | NO | | MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO | | FEDERATED | YES | Federated MySQL storage engine | NO | NO | NO | | ARCHIVE | YES | Archive storage engine | NO | NO | NO | | MyISAM | YES | Default engine as of MySQL 3.23 with great performance | NO | NO | NO | +------------+---------+----------------------------------------------------------------+--------------+------+------------+
If the ARCHIVE storage engine is displayed in the list and the support is yes, you have the option of backing up to the ARCHIVE table. If not, you should configure the myisam_max_sort_file_size and myisam_sort_buffer_size parameters.