01
The nature of the index
such as:
When we go to the toilet, we have to look at the index signs for boys and girls so that we can't go wrong.
When we visit the mall, we have to look at the floor index signs so that we can understand what is on sale and what to play on each floor.
We do daily lives index posted rules, tell us 6 : 50 to get up, 7 : 00 to eat breakfast 7 : 30 work or school ........
Let’s talk about the index today, I hope you like it.
02
What is the essence of database indexes?
What did you find in this picture?
I said: It is a tree with many branches.
I said: Green green , frog is green , the trees are green. yellow yellow , banana yellow. Pur ple is purple , and grapes are purple. Orange is orange, and oranges are orange. Blue blue. You can learn a lot of colors through this tree.
I said: Each arrow indicates a direction.
03
How does the index work?
What did you find in this picture?
I said: It is a syllable tree. The syllable has three branches, which are divided into initials, finals and tones.
I said: The initial line points to the letters bpmfdtnlgkhjqx zh ch sh rzcsyw.
I said: this line which vowel pointing AOE ai AO ou AN EI EN Ang ENG Ong i ia IE IAO IOU ian in IANG iong U UA UAI UAN uen uang ueng ü üe üan ün which these objects .
In fact, the initials, vowels, and tones are indexes and classifications.
04
What is the role of the index?
The function of index is actually a means to improve data retrieval performance.
This is a piece of student data, which contains information such as student name age phonenum .
What did you find in this picture?
I said: You can directly retrieve the personnel information of the 103 object by ID=103 . Searching for value through this ID will quickly find the catalog data, thereby improving the speed of data query. This is the actual role of the index.
05
What data structure can be used as an index?
What did you find in this picture?
In fact, everything has its advantages and disadvantages in its existence, and it is not 100% complete.
06
You only need to remember its characteristics: "Left is smaller than right, and each node has two forks";二叉搜索树的平均查找长度及时间复杂度给它带来的问题就是:IO性能差,如果树很高的话,深度很深的话,查询起来非常麻烦。
B-树(B-tree) 比如:二叉查找树,平衡二叉查找树 , 他们查找效率的时间复杂度O(log2n),跟树的深度有关系,那么怎么样才能提高效率呢?当然最快捷的方式就是减少树的深度了。那么怎么减少树的深度呢?
基本思想是:采用多叉树结构。
也就是说, 因为磁盘的操作费时费资源,过于频繁的多次查找势必效率低下。 也就是说, 只要我们通过某种较好的树结构减少树的结构尽量减少树的高度,便能有效减少磁盘查找存取的次数。 那这种有效的树结构是一种怎样的树呢?
B-树(B-tree) 可以理解是种:多路平衡树,它实际就是体现在数据中就是多个关键字,通过多个关键字的索引创建,就能在大数据量的数据中查询检索出你想定位的数据信息。
07
其实讲了这么多,那最后咱们总结一下吧。
索引本质是什么?
你在这张图中发现并看到了什么?
索引就是一种指示、一种方向标。
08
(公众号)
(微信)
09
[ Writing instructions ] The above content is shared with programmers who like to program and have dreams, and hope to help you. The above article belongs to the original public account. If you need to reprint, please indicate the source. [ Disclaimer ] This public platform is not an advertiser, nor does it advertise for other third-party websites or individuals. The source code and articles shared here are some of the projects that I think are good in the project and study. Some voluntary download or payment behaviors generated by users. There is no direct relationship with the platform [ Submission Email ] [email protected] Welcome to contribute and share your high-quality source code or articles