Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The use of mysql database index

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the use of mysql database index, the contents of the article are carefully selected and edited by the author, with a certain pertinence, for everyone's reference significance is still relatively great, the following with the author to understand the use of mysql database index.

The official definition of an index by MySQL is that an index is a data structure that helps MySQL obtain data efficiently.

We can simply understand it as: quickly find a sorted data structure.

There are two main structures of Mysql index: B+Tree index and Hash index.

The index we usually talk about, if not specifically specified, generally refers to the index organized by the B-tree structure (B+Tree index). The index is shown in the figure above.

The outermost light blue disk block 1 contains data 17, 35 (dark blue) and pointers P1, P2, P3 (yellow). The P1 pointer represents blocks less than 17, P2 is between 17 and 35, and P3 points to blocks greater than 35. The real data exists in the cotyledon node, that is, the bottom layer 3, 5, 9, 10, 13. Non-leaf nodes do not store real data, but only data items that guide the search direction, such as 17 and 35.

Search process: for example, to search for 28 data items, first load disk block 1 into memory, occur an Icano, and use a binary search to determine the P2 pointer. Then it is found that 28 is between 26 and 30, and disk block 3 is loaded into memory through the address of the P2 pointer, and the second Ihand O occurs. Disk block 8 is found in the same way, and the third I _ hand O occurs.

The truth is, the upper three layers of B+Tree can represent millions of data, millions of data occurred only three times, instead of millions of times, the time boost is huge.

After reading the above about the usefulness of mysql database index, many readers must have some understanding. If you need to get more industry knowledge and information, you can continue to follow our industry information column.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report