MySQL insert performance test_mysql

Source: Internet
Author: User
MySQL insertion performance test objective

Compared with the performance differences between myisam and innodb, the batch insert effect is as follows.

Test process Environment

Sync_binlog = 0

Innodb_flush_method = O_DIRECT

Innodb_flush_log_at_trx_commit = 2

Total number of inserts per time:

Table structure

Note: The ip varchar (255) comes from the service and is not modified here.

Create table 'wm _ buz_consume_time_log '(
'Id' int (10) not null AUTO_INCREMENT COMMENT 'primary key ',
'Wm _ poi_id 'int (11) not null comment,
'App _ type' tinyint (2) DEFAULT '0 ′,
'URL 'varchar (1024) default null comment' access url ',
'Consumer _ time' int (11) DEFAULT '0' COMMENT 'response time ',
'IP' varchar (255) default null,
'Ctime' int (11) default null comment' creation time ',
Primary key ('id ')
)

Single INSERT
Innodb Myisam
Single Thread 3688 4600
4 threads 3400 4600
16 threads 3200 4600
Batch Insert
Engine Record/insert Insert/second Record/second
MyISAM 10 3554.22762529 35542.3
50 1982.53113005 99126.6
100 1117.44688596 111745
200 599.321012222 119864
300 399.327219915 119798
400 298.744724058 119498
500 246.173864279 123087
Inoodb 10 1987.27785192 19872.8
50 790.588036815 39529.4
100 510.040947166 51004.1
200 324.766895247 64953.4
300 203.101339928 60930.4
400 174.502397867 69801
500 142.428435136 71214.2
Test conclusion

MyISAM is not affected by the number of threads because of table-level locks. MyISAM is significantly faster than INNODB (INNODB has locks and transaction overhead) and has a high single thread.27%As the number of threads increases, the advantage is more obvious.

The performance of MyISAM batch insert is significantly improved. after a single batch reaches 100, the insert speed is basically stable, which can reach Records/s, which is a single insert.24 times.

The performance of Innodb batch inserts is improved significantly. as the number of batch inserts increases, the performance continues to increase. the number of batch inserts can reach 100 records/s, which is a single insert.14XBut only MyISAM50%.

Although MyISAM has much faster insertion performance than INNODB, we recommend INNODB + batch writing because MyISAM has a table crash problem (when there are many indexes in a large table, recovery takes a long time and cannot be read or written during the recovery process). In addition, too many batches are not recommended. the risk of exceeding max_allowed_packet may cause the database to be not smooth in many links.

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.