标签:man redo 实现 引擎 lis lan 引入 image index
怎样存储page,文件中的page
# 通过citydi找到page_id + offset
postgres=# select ctid,* from r;
ctid | id | val
-------+-----+-----
(0,1) | 101 | aaa ~~ page为0的第一个记录
(0,2) | 102 | bbb
(0,3) | 103 | ccc
# 删除是不会直接回收的
postgres=# delete from r where id=102;
DELETE 1
postgres=# select ctid,* from r;
ctid | id | val
-------+-----+-----
(0,1) | 101 | aaa
(0,3) | 103 | ccc
# 插入新的数据会顺延
postgres=# insert into r values(104,‘ddd‘);
INSERT 0 1
postgres=# select ctid,* from r;
ctid | id | val
-------+-----+-----
(0,1) | 101 | aaa
(0,3) | 103 | ccc
(0,4) | 104 | ddd
(3 rows)
# 重整后数据会挪动
postgres=# vacuum full;
VACUUM
postgres=# select ctid,* from r;
ctid | id | val
-------+-----+-----
(0,1) | 101 | aaa
(0,2) | 103 | ccc
(0,3) | 104 | ddd
# 8.0.20
# 根据表明找到TABLE_ID
mysql> select TABLE_ID,NAME from INNODB_TABLES where NAME=‘sbtest/sbtest1‘;
+----------+----------------+
| TABLE_ID | NAME |
+----------+----------------+
| 1065 | sbtest/sbtest1 |
+----------+----------------+
# 根据主键找到root page
mysql> select INDEX_ID,NAME,TYPE,PAGE_NO,SPACE from INNODB_INDEXES where TABLE_ID=1065 and NAME=‘PRIMARY‘;
+----------+---------+------+---------+-------+
| INDEX_ID | NAME | TYPE | PAGE_NO | SPACE |
+----------+---------+------+---------+-------+
| 151 | PRIMARY | 3 | 4 | 4 |
+----------+---------+------+---------+-------+
# 根据SPACE找到物理文件
mysql> select * from INNODB_DATAFILES where SPACE=4;
+--------------+----------------------+
| SPACE | PATH |
+--------------+----------------------+
| 0x34 | ./sbtest/sbtest1.ibd |
+--------------+----------------------+
# 二叉树的根节点在 ./sbtest/sbtest1.ibd文件 + PAGE_NO[4]的位置
# 根据二叉树找到对应的数据的page_id
# 然后在page中找满足条件的slot
# 不同于pg,MySQL表中并没有直接记录record对应的pageid + offset信息
https://dev.mysql.com/doc/internals/en/innodb-page-directory.html
https://dev.mysql.com/doc/refman/8.0/en/innodb-information-schema-system-tables.html
标签:man redo 实现 引擎 lis lan 引入 image index
原文地址:https://www.cnblogs.com/Alpes/p/13187033.html