MySQL delayed Index Update (delay_key_write), delaykeywrite

Source: Internet
Author: User

MySQL delayed Index Update (delay_key_write), delaykeywrite

MySQL Delayed Index Update (Delayed Key Write ):

The myisam Table created using the table creation option DELAY_KEY_WRITE will not write the index change data to the disk after the query ends, but will be In the memory healthy buffer (In-memory key buffer) cache index change data. It dumps the index block to the disk only when the cache area is cleared or the table is closed. This mode greatly improves the processing performance of tables that frequently change data and are used.


However, if the server or system crashes, the index will be damaged and need to be repaired. You can use a script, such as running the myisamchk tool, to fix the problem before restarting the server, or use the Automatic Repair Option (even if the DELAY_KEY_WRITE option is not selected, these repair security measures are also very valuable ). The delayed update index feature can be configured globally or separately for individual tables.


MySQL database parameter DELAY_KEY_WRITE:

DELAY_KEY_WRITE indicates that, before the table is closed, only data is updated to the disk for the update operation on the table, instead of the index to the disk, and the changes to the index are recorded in the memory. (The function of this option is to temporarily stop MySQL from refreshing the index immediately after each new record is inserted and each new record is modified, refresh the index until all records are inserted/modified)

In this way, the MyISAM table can make index updates faster. When the table is closed, the index is updated to the disk.


Usage:1: Specify DELAY_KEY_WRITE when creating table.

2: When the TABLE already exists: alter table table_name DELAY_KEY_WRITE = 1.


Scenario:The table has the update operation, and duang has the advantage. Because this parameter can delay updating the index to the table. You can use this parameter when updating a large table.


TIPS:When DELAY_KEY_WRITE is used, if a restart or power loss occurs, the index update in the cache cannot be updated. Therefore, you must add -- myisam-recover to the startup parameter, in this way, when you start mysql, you will check your table and synchronize the table and index. or run myisamchk before restarting the server. With this feature, the app -- myisam-recover option is used to start the server and add automatic checks for all MyISAM tables.


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.