MySQL large data import and export method comparison

Source: Internet
Author: User

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 Export as Text

Method: SELECT * into outfile '/backup/yejr.txt ' from Yejr;

Time consuming: 3252.15 seconds

1.2 exported as. sql files

Method: Mysqldump-t-n--default-character-set=latin1 test Yejr >/backup/yejr.sql

Time Consuming: 2124 sec

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

2. Import Test

2.1 Import TXT file

Method: MySQL Test </backup/yejr.txt

Time Consuming: 3317.62 sec

2.2 Importing SQL files

Method: MySQL Test </backup/yejr.sql

Time Consuming: 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.

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.