当前位置:网站首页>Mysql的B+树高度计算
Mysql的B+树高度计算
2022-07-28 19:51:00 【棒棒吃不胖】
问题
假设B+树的高度是2,一行数据的记录大小是1K,主键ID是int类型。
问:该B+树存放的总记录数?
知识点
Mysql的默认存储引擎是Innodb
Innodb的最小存储单位是页
一页大小等于16K
B+树的叶子节点存放数据,内部节点存储键值和指针
在高度为2的B+树情况下,
B+树存放总记录=单个叶子节点的记录行数 * 根节点指针数
解决过程
1)计算单个叶子节点的记录行数
单个页的大小是16K
一行数据大小是1K
所以行数=16K / 1K =16
2)计算根节点指针数
一个int类型的字符长度是4字节
在Innodb中设置中一个指针长度是4字节
共计8个字节
所以根节点指针数=16KB / 8B = 16 * 1024B / 8B = 2048
根据公式:B+树存放总记录=2048 * 16 = 32768
综上所述:高度为2且满足上述条件的B+树存放记录32768条
补充说明:
如果B+树高度为3,B+树存放记录为
2048 * 2048 * 16 = 67108864
由此可见,B+树高度超过3时,磁盘IO迅速增大,SQL查询压力也会急剧增加。
边栏推荐
- (PMIC) full and half bridge drive csd95481rwj PDF specification
- NTP server time (view server time)
- Bus, protocol, specification, interface, data acquisition and control system in industrial communication field
- 1162. Map analysis - non recursive method
- Bully is filed for bankruptcy! The company has become a "Lao Lai", and the legal person is restricted from high consumption
- C process control statement
- Uncaught Error:Invalid geoJson format Cannot read property ‘length‘ of undefind
- SQL server中提示对象名无效
- 微星宝安工厂失火!官方回应:无人员受伤,产线不受影响!
- MySQL 是如何归档数据的呢?
猜你喜欢

JVM 内存布局详解(荣耀典藏版)
![Leetcode 19. delete the penultimate node of the linked list [knowledge points: speed pointer, recursion, stack]](/img/86/c74a63c3465efbed74c2bf059bac4f.jpg)
Leetcode 19. delete the penultimate node of the linked list [knowledge points: speed pointer, recursion, stack]

Meta opens the project aria pilot dataset and will develop real-time 3D maps in the future

PyQt5快速开发与实战 5.4 网页交互

Leetcode linked list problem -- 142. circular linked list II (learn the linked list by one question and one article)

Study and use of cobalt strike

基于复杂网络的大群体应急决策专家意见与信任信息融合方法及应用

到底为什么不建议使用SELECT * ?

35 道 MySQL 面试必问题图解,这样也太好理解了吧

Quii Cordova plugin telerik imagepicker plug-in multi image upload out of sequence
随机推荐
LT7911D Type-C/DP转mipi 方案成熟可提供技术支持
入行4年,跳槽2次,我摸透了软件测试这一行~
Maintenance of delta hot metal detector principle analysis of v5g-jc-r1 laser measurement sensor / detector
【Bluetooth蓝牙开发】八、BLE协议之传输层
Hold high the two flags of 5g and AI: Ziguang zhanrui Market Summit is popular in Shencheng
多线程顺序运行的 4 种方法,面试随便问
Discussion: if you want to land Devops, is it enough to only consider a good PAAS container platform?
苹果M1处理器详解:性能及能效成倍提升,Intel酷睿i9也不是对手!
The Swedish court lifted the 5g spectrum auction ban on Huawei and ZTE
Capture video by buffering
小霸王被申请破产!公司成“老赖” ,法人被限制高消费
Coolpad voluntarily terminated the patent infringement lawsuit against Xiaomi
DELTA热金属检测器维修V5G-JC-R1激光测量传感器/检测仪原理分析
Priced at 1.15 billion yuan, 1206 pieces of equipment were injected into the joint venture! Sk Hynix grabs the mainland wafer foundry market!
The 35 required questions in MySQL interview are illustrated, which is too easy to understand
Assign a string pointer to an array [easy to understand]
聊一聊数据库的行存与列存
Uncaught Error:Invalid geoJson format Cannot read property ‘length‘ of undefind
How to measure software architecture
Bug of Dom4j