MySQL Index review notes

Source: Internet
Author: User

Index Type:

1. General Index

Create index index_name on test_table (column_name (length));

2, unique index, can have a null value

Create Unique Index  on test_table (column_name (length));

3, primary key index, can not be empty

4, combined index, follow the "leftmost prefix"

Create Index  on test_table (Column_name1 (Ten), Column_name2,column_name3);

When the table is built, the column_name1 length is 16, which is used here in 10. This is because, in general, the length of the name does not exceed 10, which speeds up the index query, reduces the size of the index file, and increases the update speed of the insert.

If you set up a single-column index on Column_name1,column_name2,column_name3, so that the table has 3 single-column indexes, the efficiency of the query and the combined index above is very different, much lower than our combined index. Although there are three indexes at this point, MySQL can only use one of the single-column indexes that it considers to be the most efficient.

The establishment of such a composite index, in fact, is equivalent to the following three sets of composite indexes:

(Column_name1,column_na

MySQL uses indexes only on <,<=,=,>,>=,between,in, and sometimes like.

MySQL Index review notes

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.