Efficiently traversing InnoDB B+Trees with the page directory--slot
Efficientlytraversing InnoDB B+Trees with the page directory
1、the purpose of the page directory
As described in the posts mentioned above,all records in INDEX pages are linked together in a singly-linked list inascending order. However, list traversal through a page with potentiallyseveral hundred records in it is very expensive: every record’s key
must becompared, and this needs to be done at each level of the B+Tree until therecord sought is found on a leaf page.
Index page页中的全部记录都以单链表递增的形式串联。可是在一页中以链表的形式检索记录代价非常大:每个记录的key必须比較,这个动作须要在全部高度的B+树上进行,知道在叶子节点找到记录。
The page directory greatly optimizes thissearch by providing a fixed-width data structure with direct pointers to 1 ofevery 4-8 records, in order. Thus, it can be used for a traditional binarysearch of the records in each page, starting at the mid-point
of the directoryand progressively pruning the directory by half until only a single entryremains, and then linear-scanning from there. Since the directory iseffectively an array, it can be traversed in either ascending or descendingorder, despite the records
being linked in only ascending order.
Page directory通过提供一个固定大小的数据结构(这个结构指向4-8个记录中的一个)优化查询。
因此可以在每一个页中使用二叉查找的方法。依据slot折半查找,知道仅仅剩下一个条目。然后从这个条目开水线性扫描。因为directory是一个高效的数组。可以以递增或者递减的顺序进行扫描。即使记录仅仅是以递增的顺序链接。
2、The physical structure of the pagedirectory
The structure is actually very simple. Thenumber of slots (the page directory length) is specified in the first field ofthe INDEX header of the page. The page directory always contains an entry forthe infimum and supremum system records (so the minimum size
is 2 entries), andmay contain 0 or more additional entries, one for each 4-8 system records. Arecord is said to “own” another record if it represents it in the pagedirectory. Each entry in the page directory “owns” the records between theprevious entry in
the directory, up to and including itself. The count ofrecords “owned” by each record is stored in the record header that precedeseach record.
Slots的个数在该页的index header部分的第一域指定。Page directory至少包括infimum和supremum的slot。
因此directory最少有2个slot。一个记录假设own其它记录,表示在这个slot里。每一个slot管理本身和上一个slot中的记录之间的记录。记录owned的个数存在每一个记录的record header部分。
The page-directory-summary mode of innodb_spacecan be used to view the page directory contents, in this case for a completelyempty table (with the same schema as the 1 million row table used in A quickintroduction to innodb_ruby), showing the minimum possible
page directory:
$ innodb_space -f t_page_directory.ibd -p 3page-directory-summary
slot offset type owned key
0 99 infimum 1
1 112 supremum 1
If we insert a single record, we can seethat it gets owned by the record with a greater key than itself that has anentry in the page directory. In this case, supremum will own the record (aspreviously discussed, supremum represents a record higher than any
possible keyin the page):
$ innodb_space -f t_page_directory.ibd -p 3page-directory-summary
slot offset type owned key
0 99 infimum 1
1 112 supremum 2
The infimum record always owns only itself,since no record can have a lower key. The supremum record always owns itself,but has no minimum record ownership. Each additional entry in the pagedirectory should own a minimum of 4 records (itself plus 3 others)
and amaximum of 8 records (itself plus 7 others).
Infimum记录总是仅仅own自己,由于是最小记录。
Supremum记录总是own自己。
除了infimum和supremum的slot,每一个slot都会至少管理4个记录(itself+3others)。最多管理8个。
To illustrate, each record with an entry inthe page directory (bolded) owns the records immediately prior to it in thesingly-linked list (K = Key, O = Number of Records Owned):
3、Growth of the page directory
Once any page directory slot would exceed 8records owned, the page directory is rebalanced to distribute the records into4-record groups. If we insert 6 additional records into the table, supremumwill now own a total of 8 records:
一旦一个slot管理的记录超过8个,slot就会将之分成4个记录为一组。假设我们个记录。
$ innodb_space -f t_page_directory.ibd -p 3page-directory-summary
slot offset type owned key
0 99 infimum 1
1 112 supremum 8
The next insert will cause are-organization:
在插入一个记录会引起重组
$ innodb_space -f t_page_directory.ibd -p 3page-directory-summary
slot offset type owned key
0 99 infimum 1
1 191 conventional 4
2 112 supremum 5
4、A logical view of the page directory
At a logical level, the page directory (andrecords) for a page with 24 records (with keys from 0 to 23) would look likethis:
Infimum总是仅仅own自己,该slot的n_owned=1
Supremum总是owns一个页中最后几个记录,个数能够小于4.
其它slot至少有4个记录最多8个。
逆序排放。从16376个字节開始。即FIL trailer的開始位置。
Take note that:
Records are singly linked from infimum tosupremum through all 24 user records, as previously discussed.
Approximately each 4th record is enteredinto the page directory, represented in the illustration both by bolding thatrecord and by noting its offset in the page directory array represented at thetop of the illustration.
The page directory is stored “backwards” inthe page, so is reversed in this illustration compared to its ordering on disk.
记录是单链表形式链接
http://blog.jcole.us/2013/01/
Efficiently traversing InnoDB B+Trees with the page directory--slot的更多相关文章
- innodb数据结构
Jeremy Cole on InnoDB architecture : Efficiently traversing InnoDB B+Trees with the page directory ...
- MySql基础入门-mysql体系结构
mysql体系结构: 由:连接池组件.管理服务和工具组件.sql接口组件.查询分析器组件.优化器组件. 缓冲组件.插件式存储引擎.物理文件组成. mysq ...
- MySQL的InnoDB索引原理详解
摘要 本篇介绍下Mysql的InnoDB索引相关知识,从各种树到索引原理到存储的细节. InnoDB是Mysql的默认存储引擎(Mysql5.5.5之前是MyISAM,文档).本着高效学习的目的,本篇 ...
- MySQL内核:InnoDB存储引擎 卷1
MySQL内核:InnoDB存储引擎卷1(MySQL领域Oracle ACE专家力作,众多MySQL Oracle ACE力捧,深入MySQL数据库内核源码分析,InnoDB内核开发与优化必备宝典) ...
- MySQL的InnoDB索引原理详解 (转)
摘要: 本篇介绍下Mysql的InnoDB索引相关知识,从各种树到索引原理到存储的细节. InnoDB是Mysql的默认存储引擎(Mysql5.5.5之前是MyISAM,文档).本着高效学习的目的,本 ...
- innodb的表最大限制
相信大多数人都不知道,innodb的表最大限制为64TB,但是why? Each space is divided into pages, normally 16 kib each (this can ...
- MySQL:InnoDB存储引擎的B+树索引算法
很早之前,就从学校的图书馆借了MySQL技术内幕,InnoDB存储引擎这本书,但一直草草阅读,做的笔记也有些凌乱,趁着现在大四了,课程稍微少了一点,整理一下笔记,按照专题写一些,加深一下印象,不枉读了 ...
- MySQL · 引擎特性 · InnoDB 事务锁简介
https://yq.aliyun.com/articles/4270# zhaiwx_yinfeng 2016-02-02 19:00:43 浏览2194 评论0 mysql innodb lock ...
- innodb结构解析工具---innodb_ruby
1.下载ruby并安装ruby: ftp://ftp.ruby-lang.org/pub/ruby/ ftp://ftp.ruby-lang.org/pub/ruby/ruby-2.3-stable. ...
随机推荐
- 如何使用python发送邮件
使用python发送邮件,用的是SMTP协议. 因此在qq邮箱中,要设置开启SMTP服务 只要能开启一个就行 在我们执行程序的时候,会发现邮件被发送过来了 在python中还有一个更简单的第三方模块, ...
- JMeter乱码问题的解决
一.JMeter返回数据是乱码 解决办法是: 在JMeter安装路径的bin目录下,以记事本打开文件jmeter.properties, 找到Sampleresult.default.encoding ...
- Centos下zabbix部署(二)agent安装并设置监控
1.配置zabbix源 rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch ...
- hdu 5125(LIS变形)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5125 题解: 这个题dp[i][0],dp[i][1]数组分别记录在第i个位置取a[i]和b[i]时 ...
- 安装CentOS 7 遇到的坑
1,U盘安装 1.1 用最新版UltraISO刻录到U盘 坑1,如果之前不是用UltraISO刻录,或者不是最新版,u盘的label就不是系统自带的,当你选择install centos 7然后ta ...
- 51nod 1420 数袋鼠好有趣【贪心】
1420 数袋鼠好有趣 题目来源: CodeForces 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 收藏 关注 有n只袋鼠.每只袋鼠的大小用一个整数表示. ...
- HDU 6395 2018 Multi-University Training Contest 7 (快速幂+分块)
原题地址 Sequence Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)T ...
- 数学【p2117】 小z的矩阵
题目描述-->p2117 小z的矩阵 分析: 题目给定我们一个正方形. 容易想到,正方形是对称的. 推敲一下 如果我们的矩阵是这样的↓ 闭眼瞎敲出来的. \[\begin{bmatrix} {0 ...
- HKSCS
香港增补字符集(HKSCS) 背景介绍 背景资料 ======== 目前,大部份不同語文的電腦系統,都有不同的編碼標準.如中文的系統就有BIG5和GB2312/GBK.各種文字有不同的文字編碼,不同系 ...
- UVA 11990 ”Dynamic“ Inversion(线段树+树状数组)
[题目链接] UVA11990 [题目大意] 给出一个数列,每次删去一个数,求一个数删去之前整个数列的逆序对数. [题解] 一开始可以用树状数组统计出现的逆序对数量 对于每个删去的数,我们可以用线段树 ...