Mysql index concept and design principles

Source: Internet
Author: User
Tags mysql index

Key type:

1. Primary key

2. Unique key

3. Foreign key

Index Type:

1. Hash index

2. Ordered index (btree/rtree)

Creation of the index:

1. Primary key creates two indexes: Hash index and ordered index

2. Unique key creates two indexes: Hash index and ordered index

3. Generally defined indexes create only ordered indexes

Primary key and unique key each index uses the scene:

1. When the operation type is =, use the hash index

2. When the operation type is range, use the ordered index

Index usage principles:

1. The primary key-based operation is the fastest and requires the full use of the primary key

2. For primary and unique keys if no scope operation is required, we recommend using the using hash to restrict the primary key and unique key to create only the hash index

3. Index based on type int is faster than the varchar type based index speed

Mysql index concept and design principles

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.