Skip to Content
数据库系统内幕
book

数据库系统内幕

by Alex Petrov
May 2020
Beginner to intermediate
319 pages
7h 3m
Chinese
China Machine Press
Content preview from 数据库系统内幕
122
|
第
7
章
已刷写的表
一旦被刷写的 memtable 被丢弃,就可以被用于读取。
正在被压实的表
当前正在被合并的磁盘驻留表。
已被压实的表
由已刷写的表或其他已压实的表所创建。
磁盘
读
读
读
读 写
内存
切换
刷写
刷写目标
已刷写的表
正在被压实
的表
当前
memtable
正在刷写的
memtable
已被压实的表
读
图
7-4
:
LSM
的组件结构
数据已经在内存中进行了排序,因此可以通过将内存驻留的内容依次写入磁盘来创建磁
盘驻留表。在刷写期间,正在刷写的 memtable 和当前的 memtable 都可供读取。
在完全刷写memtable 之前,其内容唯一的磁盘驻留版本储存在预写日志中。当
memtable 内容被完全刷写到在磁盘上时,日志可以被
修剪
(trim),并且保存对被刷写过
的 memtable 进行的操作的日志段可以被丢弃。
7.1.2
更新与删除
在 LSM 树中,插入、更新和删除操作不需要在磁盘上定位数据记录。但是,在读取的
过程中需要对冗余的记录进行协调。
从 memtable 中删除数据记录是不够的,因为其他磁盘或内存驻留表可能持有同一个键
的数据记录。如果仅通过从 memtable 中移除数据项来实现删除,那么要么最终删除无
效,要么我们会
复活
(resurrect)先前的数值。
让我们考虑一个例子。被刷写的磁盘驻留表中包含与记录 v1 相关联的键 k1,而
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