Mysql table performance improvement question _ MySQL

Source: Internet
Author: User
DROPPRIMAYDEY is used to cancel the primary index. Note: in earlier versions of MySQL, if there is no primary index, DROPPRIMARYKEY will cancel the first UNIQUE index in the table. This does not happen in MySQL5.1. If you use dr drop primay dey to cancel a primary index for a table without a primary key in MySQL5.1.

Note: in earlier versions of MySQL, if there is no PRIMARY index, drop primary key will cancel the first UNIQUE index in the table. This does not happen in MySQL 5.1. If you use drop primary key for a table without a primary key in MySQL 5.1, an error message is displayed.

If you add a unique key or primary key to the table, the unique key or primary key is stored before a non-UNIQUE index, so that MySQL can check duplicate keywords as soon as possible.

Order by is used to sort the rows in a certain ORDER when creating a new table. Note: After insertion and deletion, the table will not remain in this order. You can use this option when you know that you will query rows in a specific order in most cases. after making a major change to the table, you can use this option, you can improve query efficiency. In some cases, sorting by column may be easier for MySQL.

If you use alter table for a MyISAM TABLE, all non-unique indexes are created in a separate batch (the same as the repair table ). When you have many indexes, this can make alter table faster.

This function can be explicitly activated. Alter table... disable keys: stop MySQL from updating non-unique indexes in the MyISAM TABLE. Then use alter table... enable keys to recreate the lost index. During this operation, MySQL uses a special algorithm, which is much faster than inserting keywords one by one. Therefore, disabling keywords before batch insertion can greatly speed up. Using alter table... disable keys requires the INDEX permission in addition to the previously mentioned permissions.

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.