MySQL index must know

                                                        

 

MySQL index must know will be

 

 

What is the index?

In a relational database, the index is a storage structure of a single, physical values ​​of the database tables in one or more columns to sort, which is a table or a plurality of columns and corresponding table pointing value list of pointers logical pages in the physical identification data of these values.

For example: there is a student table, which records 5W, 5W students record this information. Which has a sno field record of each student's school, now want to check out the school number XXXX person's information.

In the absence of the index, the data we need to traverse the table one by one in. After matching the query to the data, first put the data into the result set, and then to research all of the data until the query is completed.

The advantage of index

  1. The most obvious advantage of the index is to reduce the speed of queries and improve the efficiency of the database.

    • Data retrieval time can be shortened by index query

    • You can speed query time correlation between the table and the table through an index

  2. Ordered or grouped increasing index fields can improve efficiency of sorting and grouping.

 Shortcoming index

  1. Time to create an index of the cost will increase as the amount of data increases.

  2. After the index is created, after the data in the database tables to add, delete, change and other operations, the corresponding index also needs to be maintained, reducing data rate maintenance.

  3. In essence, the index is through trade off space for time. In other words, we reduce the time cost of a query at the same time, it is bound to sacrifice the cost of disk space to store the index.

Published 60 original articles · won praise 58 · Views 140,000 +

Guess you like

Origin blog.csdn.net/yihuliunian/article/details/105387362