Mysql Database Study Notes index and mysql Study Notes

Source: Internet
Author: User

Mysql Database Study Notes index and mysql Study Notes

What is an index:

There are two types of SQL indexes: clustered index and non-clustered index. The index aims to improve the performance of the SQL Server system, speed up data query, and reduce the system response time.

Clustered index: the logical order of the key values in the index determines the physical order of the corresponding rows in the table.

Non-clustered index: the logical order of the index is different from that of the physical storage on the disk.

Here are two simple examples:

We come up with a Xinhua Dictionary. Its Directory is actually an index: Non-clustered index. We can quickly locate the words we want to query through the directory. The contents of the dictionary are generally sorted by pinyin, which is actually an index: clustered index.

Benefits of creating an index:

1. Accelerate the search speed of frequently searched fields.

2. Use the uniqueness of indexes to control the uniqueness of records

Disadvantages of Indexing:

At least the following additional storage space will be created for an index (a single index occupies 5% to 15% of the original table space. Imagine if you create three or four indexes for a table) the additional maintenance time is only for one purpose: reduce the query time in the case of small-scale queries. If the query returns more than 1% of the data, the index is meaningless.

When to use indexes:

If a field or a group of fields appear in a where clause that will be frequently called, they should be indexed to get results faster. At the same time, the use of unique Indexes has been mentioned earlier, so that they can be used properly to avoid unexpected occurrence. I personally do not recommend full-text indexing. Especially for Chinese characters, full-text indexing is too costly. I would rather choose the intra-site search function provided by the search engine. Although search engine indexing is not timely, I don't think it is unacceptable. Again, I think we should try to do more things when inserting, modifying, and deleting data. These operations are relatively less frequent, and the data volume of a single operation is smaller. Do not leave all pressure to query statements.

 

My blog address: index of Mysql Database Study Notes)

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.