当前位置:网站首页>B+树(4)联合索引 --mysql从入门到精通(十六)
B+树(4)联合索引 --mysql从入门到精通(十六)
2022-07-26 12:55:00 【用户9919783】
上篇文章介绍了主键索引(聚簇索引),二级索引(非主键索引,辅助索引),主键索引查询通过根目录记录查询对应的数据页目录。二级索引查询先查询列+页码名称的目录非叶子节点,之后在查询到叶子节点,此刻叶子节点上存储的是主键和列,在通过主键查询整条数据。
B+树(3)聚簇索引,二级索引 --mysql从入门到精通(十五)
联合索引
联合索引又称复合索引,比方说我们想让b+树按c2,c3两个列进行大小排序,那意思是:1)先按c2进行排序。2)c2相同的情况下,按c3排序。
所以现在底层叶子节点记录着:c2,c3,和他对应的主键c1,目录记录非叶子节点记录着c2,c3和页码名称,先按c2进行排序,如果一样,就按c3排序。其本质也是个二级索引,但不同的是:
联合索引只有一颗b+树。
如果为c2,c3分别建立索引有两颗b+树。
InnoDB索引树注意事项:
根节点保持不变
B+树的形成过程,1)给新表建立主键索引(聚簇索引),聚簇索引不是人为创建的,默认就有,此刻就会创建根节点页面,里面没有数据。2)随后插入用户记录数据,吧数据放入根节点。3)当根节点空间用完,此刻进行页分裂操作,得到新的页,此刻目录记录节点会放主键值和页码或者二级索引的列值和页码,底层叶子节点放用户记录和主键值,或者主键值和列值,而根节点升级为目录记录根节点。
内节点目录项唯一性
二级索引的内节点存储的是列值,但因为列值,比如姓名没有唯一性,可能有两个重名甚至更多重名的,这时候如何辨识他的唯一性呢,所以二级索引在目录页存储的不仅仅是列值+页码名称,还会带上当前行记录唯一主键,所以内节点存储的内容是列值+主键+页码。
一个页面最少存储两条记录
我们知道b+树只要三层层级就能存储庞大的数据,查询效率非常高,每次往下查询都会过滤掉很多没必要的子目录,那如果一个大目录页只放一个子目录是什么效果呢?那层级目录会非常非常多,而且最后存放用户记录数据只有一条数据。所以innoDB设置最少存放两条数据,这也是我们之前说的行格式时候说的结论。(表中只有一列的时候,不发生行溢出的情况下,能存多少字节,65535个字节)
边栏推荐
- Use grid to realize left, middle and right layout, and the middle content is adaptive
- 基于WebRTC和WebSocket实现的聊天系统
- Can MySQL customize variable parameter storage functions?
- Kubernetes - Introduction to PV and PVC of advanced storage
- 华为年内二度招聘“天才少年”;540万Twitter账号信息泄露,卖价3万美元;谷歌解雇了相信AI有意识的工程师|极客头条...
- Data query function
- Kubernetes----Kubernetes常用插件简介
- 火山引擎云上增长方案全景:30+方案齐出,兵发优势领域
- Data query where
- Sword finger offer 24. reverse the linked list
猜你喜欢

Panorama of volcanic engine cloud growth plan: 30 + plans come out together, and military development advantage areas

如何面对科技性失业?

Sword finger offer 24. reverse the linked list

华为年内二度招聘“天才少年”;540万Twitter账号信息泄露,卖价3万美元;谷歌解雇了相信AI有意识的工程师|极客头条...

0基础编程资源大全(先收藏~慢慢看~)

【5GC】什么是5G切片?5G切片如何工作?

基于ASP.NET的某高校学院档案管理系统

Code error reporting and problem solving experience II: test error reporting in yolov5

0 basic programming resources (collect first ~ read slowly ~)

C#把Type当做泛型T,来作为方法的泛型进行使用
随机推荐
基于WebRTC和WebSocket实现的聊天系统
JDBC gets connections from the connection pool (Druid connection pool)
In the digital era, what "golden treasure" is driving the development of pharmaceutical enterprises for a century?
[5g] what are Cu and Du in 5g?
Transactional transaction propagation behavior?
Flutter dart generates a list of random numbers that are not repeated in n intervals
Flutter textfield sets the height and automatically wraps lines, and the rounded border removes the underline
基于Bézier曲线的三维造型与渲染
V00 - do whatever you want when you are old
最好的工程师,就是这样被你“逼”走的!
Guys, how can CDC Oracle set the reading from the specified SCN number, or how to set the read-only full archive, not to read fast
From January to June, China's ADAS suppliers accounted for 9%, and another parts giant comprehensively laid out the new smart drive track
[applet] why can't the onreachbottom event be triggered? (one second)
Kubernetes---- installing and deploying NFS servers
Interviewer: how to understand QPS, TPS, RT?
[5gc] what is 5g slice? How does 5g slice work?
Use positioning to realize left, middle and right layout, and the middle content is adaptive
SLAM 02.整体框架
key&key_len&ref&filtered(4)—mysql执行计划(五十)
LCD notes (7) LCD driver framework_ Configure clock