Skip to Content
数据库系统内幕
book

数据库系统内幕

by Alex Petrov
May 2020
Beginner to intermediate
319 pages
7h 3m
Chinese
China Machine Press
Content preview from 数据库系统内幕
70
|
第
4
章
中在四个衡量指标上:内存开销、压缩性能、解压缩性能和压缩比。在选择压缩库时,
这些指标是非常重要的。
4.7
清扫与维护
到目前为止,我们主要讨论的是 B 树中面向用户的操作。但是,在查询的同时还会发生
一些其他的过程,包括维护存储完整性、回收空间、减少开销以及维持页有序。在后台执
行这些操作可以使我们节省一些时间,避免在插入、更新和删除期间为清理付出代价。
之前描述过的分槽页的设计(参见 3.5 节)需要在页上执行维护操作,以维持其良好的形
态。例如,内部节点中后续的分裂和合并,或叶子层上的插入、更新和删除,可能导致
页中有足够的
逻辑
空间但没有足够的
连续
空间,因为它已经碎片化了。图 4-11 展示了这
种情况的一个例子:页中仍然有一些可用的逻辑空间,但是它是碎片化的并且被两个已删
除的(垃圾)记录分割开来,在头部 / 单元格指针和单元格之间也有一些剩余的可用空间。
单元格
偏移量
可用
空间
存活的
单元格
删除的单元格
(
垃圾
)
图
4-11
:一个碎片化页的例子
B 树的遍历始于根节点。如果一条数据记录可以通过从根节点向下追踪指针到达,那么
称它为
存活的
(即可寻址的)。而不可寻址的数据记录则称为
垃圾数据
:这些记录没有被
任何地方引用,也不能被读取或解释,因此它们的内容是作废的。
你可以在图 4-11 中看到这一区别:仍然具有指向它们的指针的单元格是可寻址的,而这
便与已移除或覆盖的单元格不同。由于性能,通常不会对垃圾区域进行填零操作,因为
这些区域最终还是会被新数据所覆盖。
4.7.1
更新和删除导致的碎片 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

解密金融数据

解密金融数据

Justin Pauley

Publisher Resources

ISBN: 9787111655169