MySQL与TiDB基础知识类比

温故而知新 可以为师矣

(想自学习编程的小伙伴请搜索圈T社区,更多行业相关资讯更有行业相关免费视频教程。完全免费哦!)

一、存储模型

MySQL

在这里插入图片描述

Each tablespace consists of database pages with a default size of 16KB. The pages are grouped into extents of size 1MB (64 consecutive pages). The “files” inside a tablespace are called segments in InnoDB.
Two segments are allocated for each index in InnoDB. One is for nonleaf nodes of the B-tree, the other is for the leaf nodes. Keeping the leaf nodes contiguous on disk enables better sequential I/O operations, because these leaf nodes contain the actual table data.

  • 表空间Tablespace(ibd文件)
  • 段Segment(一个索引2个段)
  • 区Extent(1MB):64个Page
  • 页Page(16KB):磁盘管理的最小单位

从示意图可以清晰的了解到MySQL的行数据Row都是存储到数据页Page上,每个数据页的大小为16KB。然后64个数据页进而组成一个区Extent,区又是段segment组成元素,一个索引拥有两个段,其中leaf node seagment存储着逻辑上的行数据(主键索引),非主键索引存储的是主键ID。

InnoDB使用了B+树的索引模型。B+树为了维护索引的有序性,在插入新值的时候需要做必须的维护。如果在表尾插入,只需在记录后面增加,要是增加的行在表中间,就需要挪动位置给插入的行腾出空间。更糟糕的是带插入的数据页Page已经满了16KB,这时需要新申请一个新的数

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值