当前位置:网站首页>Why doesn't the database use binary tree, red black tree, B tree and hash table? Instead, a b+ tree is used
Why doesn't the database use binary tree, red black tree, B tree and hash table? Instead, a b+ tree is used
2022-06-12 05:57:00 【A little dog】
Why don't databases use binary trees 、 Red and black trees 、B Trees 、Hash surface ? It USES B+ Trees
Binary tree
If you use a binary tree , In the worst case, it will degenerate into a linked list , It's a sequential search , Traverse the entire chain .
When the amount of data is large , The number of layers will increase uncontrollably , It leads to inefficiency .
Red and black trees
Red black tree is a special balanced binary tree , He won't have the worst scenario in a binary tree , He can balance .
But there is also a problem , Because he still belongs to the binary tree , A parent node can only follow 2 Child node . If there are tens of millions of data , Then the red and black trees will be very deep and also need a lot io operation , Such a sentence can not quickly find the data we want .
B Trees
In order to solve the problem of low query efficiency caused by too deep layers of the tree , The space of each node is too small , So increase the node space , Each leaf node stores multiple index elements and corresponding multiple data.
This effectively controls the number of layers , Such a squat tree structure , Less io operation , You only need to find the corresponding leaf node search data that should be entered according to the comparison of non leaf node index elements .
B+ Trees
B There's another problem with trees , Because non leaf nodes are also stored data data , It takes up a lot of space .B+ Non leaf nodes in the tree data Data deletion , Instead, it simply places redundant indexes and corresponding node addresses , In this way, a non leaf node can store more redundant indexes , When looking for , Use binary and half search for the current non leaf node .
And leaf nodes are connected by pointers , Improved interval access performance , Support range lookup .
Each layer is stored in order .

B+ The advantages of trees
- A single non leaf node can store as many index elements + Address , bring IO Reduced operation .
- All searches are for the lowest leaf node , Stable performance lookup .
- And leaf nodes have ordered linked lists , Convenient range search .
Please correct me if there is any mistake
边栏推荐
- Un mois de DDD hépatique.
- 软件项目架构简单总结
- What is the difference between ArrayList and LinkedList?
- Go interface implementation principle [advanced level]
- Chapter 7 - pointer learning
- [Yu Yue education] basic reference materials of accounting of Nanjing Normal University
- Market trend report, technical innovation and market forecast of Chinese stump crusher
- Introduction to redis high availability
- User login [next]
- Project and build Publishing
猜你喜欢

Who is more fierce in network acceleration? New king reappeared in CDN field
![Leetcode buckle -10 Regular expression matching analysis [recursion and dynamic programming]](/img/25/b3c475e2b03c39b7c576b6d01f9d56.jpg)
Leetcode buckle -10 Regular expression matching analysis [recursion and dynamic programming]

Performance optimization metrics and tools

Redis cache data consistency and problems

Heap classical problem

Towards End-to-End Lane Detection: an Instance SegmentationApproach

A preliminary understanding of function

March 22, 2021

Golang idea configures the agent to improve the speed of packages downloaded by go get

Webrtc AEC process analysis
随机推荐
Jackson - how to convert the array string with only one map object to list < map >
Leetcode simple problem: converting an integer to the sum of two zero free integers
[gin] gin framework for golang web development
Nrf52832 custom services and features
Introduction to Internet Protocol
IO system - code example
Execute sh script to prompt "[[: not found" solution. The difference between Bash and sh
Data integration framework seatunnel learning notes
User login [next]
SIM卡信号的驱动电流是多少mA,是否是可调节的?
What is the difference between ArrayList and LinkedList?
Unity VSCode不能跳转到定义
IO stream introduction
jpg格式与xml格式文件分离到不同的文件夹
Redis memory obsolescence strategy
MySQL master-slave, 6 minutes to master
Word frequency statistics using Jieba database
Halcon 3D 1 Reading 3D data
基于LFFD模型目标检测自动标注生成xml文件
[machine learning] first day of introduction