Comparison of the methods of exporting and importing MySQL large amount of data

Source: Internet
Author: User
Tags comparison backup

Hardware: Intel (R) Xeon (r) CPU 5130 @ 2.00GHz * 2, 4G RAM, 564G SAS

Software: Red Hat Enterprise Linux as Release 4 (Nahant Update 4) 2.6.9 42.ELSMP (32-bit), MySQL 5.0.27-standard-log

Total records: 1016126, average size of 46822 per line

1. Export Test 1.1 exported as text 方法: SELECT * INTO OUTFILE '/backup/yejr.txt' FROM yejr;
耗时: 3252.15 秒
1.2 exported as. sql file方法: mysqldump -t -n --default-character-set=latin1 test yejr > /backup/yejr.sql
耗时: 2124 sec

Conclusion: Using MYSQLUDMP to export data is a relatively fast method.

2. Import Test 2.1 Import TXT file 方法: mysql test < /backup/yejr.txt
耗时: 3317.62 sec
2.2 Import SQL file方法: mysql test < /backup/yejr.sql
耗时: 4706.618 sec

Conclusion:

1. Load data is a faster method

2. In the case of large data, it is best to create a good table, and also to create a good related index. Although importing is faster when there is no index, the total time to create the index after the data import is complete is much more time-consuming than if you had created it in advance.

In addition, if it is a MyISAM table, it is best to disable the index of the table before you import it, or to enable it after you have finished, or to start without creating an index, and then to create it after you import it, it will be much faster than updating the index at the same time.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.