视频
视频笔记
1.1 block
disk 的最小单位 block,block 的 address number 可被唯一的 track number、sector number 确定。 01:36
1.2 主存和 disk
05:53 disk 不能直接处理数据,需要将数据传入主存,在主存中对数据进行操作,再返回数据。 主存中的数据:数据结构(datastructure) disk 中的数据:DBMS(database management system)
1.3 寻找特点数据的时间/Index
08:53
==因为每个 block
存放的地址不确定,所以要查找特定的==
- 先确定 block 基本大小 (多少bites)
- 根据 row 的 bites 计算每个 block 能存放多少 rows
- 用 index 存放关键信息,计算一个 block 能存多少index
- 根据所需
index
个数判断需要的高级索引表个数 - 所需时间:最高级索引表 block 个数+剩余索引表个数(比如,我现在有 100 个 row、两级 index,高级 index 有 3 个 block,那么我需要查询的 block 数:3+1+1) (index 一般只包含关键信息和所在行的 pointer)
1.4 树、B+树
- M-way 树 (degree:M)
- 18:48
- 每个
node
至多有m-1
个key
,至少有[m/2]-1
个key
(except root node),至多m
个children
,至少[m/2]
个children
node
结构(以 4-way 树举例):【pointer 1】【k 1】【record pointer 1】【pointer 2】【k 2】【rp 2】【pointer 3】【k 3】【rp 3】【pointer 4】 每个child pointer
有一个record pointer
- 问题:过久的搜索时间
- B 树 (自下而上生长)
- 27:50
- [m/2]个
children
根
最少有两个 children- 所有的
leaf
在same level
- 举例:
→
→
→
→
- B+ 树
- 37:13
- 并非所有
child pointer
都有record pointer
,只有leaf node
的child pointer
有record pointer
. - 所有的
key
在leaf code
都有一个copy
. - 所有的
leaf form a linked list
- B+树比起 B 树,更像多级索引表
leaf
是第一级index
,再往上是第二级index
,以此类推。
B+树 insertions
rules
- First, give to left
- Second, give to right
- If above no work, split the node, elements should be more in the new node
- If split, you will create a father node, and parent node save the lowest value of every child expect the first child