What kinds of indexes does MySQL support

Source: Internet
Author: User
Tags mysql index value store

From the data structure angle

1. B + Tree index (O (log (n))): for the B + Tree index, you can refer to the data structure behind the MySQL index and the algorithm principle

2. Hash index:
A can only satisfy "=", "in" and "<=>" queries, and cannot use range queries
b Its retrieval efficiency is very high, index retrieval can be located at once, unlike the B-tree index need from the root node to the side point, and finally access to the page node so many IO access, so the Hash index query efficiency is much higher than the B-tree index
c Only memory storage engine display supports hash index

3. Fulltext INDEX (now supported by MyISAM and InnoDB engines)

4. R-tree index (used to create spatial indexes on GIS data types)

From the physical storage perspective

1. Clustered index (clustered)

2. Nonclustered indexes (non-clustered index)

From a logical point of view

1. Primary KEY index: Primary key index is a special unique index, no null value allowed

2, ordinary index or single-column index

3. Multi-column index (composite index): A composite index is an index created on multiple fields, and the index is used only if the first field when the index is created is used in the query criteria. To follow the leftmost prefix collection when using a composite index

4. Unique index or non-unique index

5. Spatial index: Spatial index is the index of the field of spatial data type, there are 4 kinds of spatial data types in MySQL, namely geometry, point, LINESTRING, POLYGON. MySQL uses the spatial keyword to extend the syntax to create spatial indexes that can be used to create regular index types. A column that creates a spatial index must be declared as not NULL, and the spatial index can only be created in a table where the storage engine is MyISAM

CREATE TABLE table_name[col_name data type][unique|fulltext|spatial][index|key][index_name](col_name[length])[asc|desc]

1. Unique|fulltext|spatial is an optional parameter, which represents a unique index, a full-text index and a spatial index, respectively;

2, index and key are synonyms, both function the same, used to specify the creation index

3. Col_name is the field column that needs to be indexed, and the column must be selected from multiple columns of that definition in the datasheet;

4, index_name the name of the specified index, optional parameters, if not specified, MySQL default col_name is the index value;

5, length is an optional parameter, indicating the length of the index, only the string type of the field to specify the index length;

6, ASC or desc Specify an ascending or descending index value store

What kinds of indexes does MySQL support

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.