Parse the delay-insert option of mysqldump

Source: Internet
Author: User

If you use delayed-insert to insert data, you do not need to lock the table.
./Bin/mysqldump-uroot-proot -- lock-tables -- extended-insert -- opt -- quick -- master-data test>/home/zhanghong/opdir/tmp/test. SQL
--
Lock tables 'student 'WRITE;
/*! 40000 alter table 'student 'disable keys */;
Insert into 'student 'values (16, 'hhah', 3), (17, '22', 3), (18, 'ss', 18 );
/*! 40000 alter table 'student 'enable keys */;
Unlock tables;

Using delayed-insert will not lock the table
. /Bin/mysqldump-uroot-proot -- lock-tables -- delayed-insert -- extended-insert -- opt -- quick -- master-data test>/home/zhanghong/opdir/tmp/test. SQL
/*! 40000 alter table 'student 'disable keys */;
Insert delayed into 'student 'values (16, 'hhah', 3), (17, '22', 3), (18, 'ss', 18 );
/*! 40000 alter table 'student 'enable keys */;
/*! 40103 SET TIME_ZONE = @ OLD_TIME_ZONE */;

When a thread executes the DELAYED statement on a table, a management program thread is created (if it does not exist) to process all the DELAYED statements used in the table.

· The thread checks whether the hypervisor has previously obtained the DELAYED lock. If not, it notifies the hypervisor thread to perform this operation. The DELAYED lock can be obtained even if other threads have READ or WRITE locks on the table. However, the hypervisor will wait for all alter table locks or flush table locks to ensure that the TABLE structure is up-to-date.

· The thread executes the INSERT statement, but not writes rows to the table. Instead, it copies the final rows into a queue managed by the Management Program thread. The thread prompts a syntax error, which will be reported to the client.

· Before the INSERT operation, the INSERT return is complete. Therefore, the client cannot obtain the number of duplicate records from the server or the AUTO_INCREMENT value of the generated row. (If you use c api, for the same reason, the mysql_info () function will not return anything meaningful .)

· When a row is inserted into a table, the binary log is updated by the Management Program thread. When multiple rows are inserted, the binary log is updated when the first row is inserted.

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.