How many times does mysql compile SQL statements like this?

Source: Internet
Author: User
Insertintotablevalues (null, & #039; abc & #039;, & #039; 123@qq.com & #039;); insertintotablevalues (null, & #039; abc & #039 ;, & #039; 123@qq.com & #039;); insertintotablevalues (null, & #039; abc & #039;, & #039; 123@qq.com & #039 ;); execute the statement three times and compile the statement three times in mysql... insert into table values (null, 'abc', '2017 @ qq.com ');
Insert into table values (null, 'abc', '2017 @ qq.com ');
Insert into table values (null, 'abc', '2017 @ qq.com ');
Execute this three times and compile it three times in mysql.

Such a statement
Insert into table values
(Null, 'abc', '2017 @ qq.com '),
(Null, 'abc', '2017 @ qq.com '),
(Null, 'abc', '2017 @ qq.com ');
How many times does one compile in mysql? Once Or three times

Reply content:

Insert into table values (null, 'abc', '2017 @ qq.com ');
Insert into table values (null, 'abc', '2017 @ qq.com ');
Insert into table values (null, 'abc', '2017 @ qq.com ');
Execute this three times and compile it three times in mysql.

Such a statement
Insert into table values
(Null, 'abc', '2017 @ qq.com '),
(Null, 'abc', '2017 @ qq.com '),
(Null, 'abc', '2017 @ qq.com ');
How many times does one compile in mysql? Once Or three times

The kernel is not so thorough, so the specific implementation principles of the two are not very clear.

However, it is very certain that batch insert is highly efficient. SQL Parsing is based on statements. Therefore, your first example is to Parse three SQL statements, and the second example is to parse one SQL statement.

In terms of IO consumption, each SQL statement must write a binlog. Therefore, only one batch insert operation is required. If there are many insert statements, the performance difference will be greater.

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.