楼主: liuxf666
475 6

[学习笔记] 【学习笔记】Foundations of Data Systems - B-tree storage [推广有奖]

  • 1关注
  • 3粉丝

学科带头人

54%

还不是VIP/贵宾

-

威望
0
论坛币
13008 个
通用积分
410.0729
学术水平
109 点
热心指数
112 点
信用等级
103 点
经验
71224 点
帖子
1081
精华
0
在线时间
1537 小时
注册时间
2016-7-19
最后登录
2024-3-20

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
  • B-tree storage
    • B-trees also keep key-value pairs sorted by key, which allows efficient key-value lookups and range queries.
    • B-trees break the database down into fixed-size blocks or pages, traditionally 4 KB in size (sometimes bigger), and read or write one page at a time. This design corresponds more closely to the underlying hardware, as disks are also arranged in fixed-size blocks. Each page can be identified using an address or location, which allows one page to refer to another—similar to a pointer, but on disk instead of in memory.
    • The number of references to child pages in one page of the B-tree is called the branching factor. In practice, the branching factor depends on the amount of space required to store the page references and the range boundaries, but typically it is several hundred.
    • Making B-trees reliable
      • The basic underlying write operation of a B-tree is to overwrite a page on disk with new data. It is assumed that the overwrite does not change the location of the page; i.e., all references to that page remain intact when the page is overwritten.
      • In order to make the database resilient to crashes, it is common for B-tree implementations to include an additional data structure on disk: a write-ahead log (WAL, also known as a redo log). This is an append-only file to which every B-tree modification must be written before it can be applied to the pages of the tree itself. When the database comes back up after a crash, this log is used to restore the B-tree back to a consistent state
      • An additional complication of updating pages in place is that careful concurrency control is required if multiple threads are going to access the B-tree at the same time  - otherwise a thread may see the tree in an inconsistent state. This is typically done by protecting the tree’s data structures with latches (lightweight locks). Log-structured approaches are simpler in this regard, because they do all the merging in the background without interfering with incoming queries and atomically swap old segments for new segments from time to time.
      • B-tree optimizations
        • Instead of overwriting pages and maintaining a WAL for crash recovery, some databases (like LMDB) use a copy-on-write scheme. A modified page is written to a different location, and a new version of the parent pages in the tree is created, pointing at the new location. This approach is also useful for concurrency control.
        • We can save space in pages by not storing the entire key, but abbreviating it. Especially in pages on the interior of the tree, keys only need to provide enough information to act as boundaries between key ranges. Packing more keys into a page allows the tree to have a higher branching factor, and thus fewer levels.
        • Many B-tree implementations therefore try to lay out the tree so that leaf pages appear in sequential order on disk. However, it’s difficult to maintain that order as the tree grows. By contrast, since LSM-trees rewrite large segments of the storage in one go during merging, it’s easier for them to keep sequential keys close to each other on disk.
        • Additional pointers have been added to the tree. For example, each leaf page may have references to its sibling pages to the left and right, which allows scanning keys in order without jumping back to parent pages.
        • B-tree variants such as fractal trees [22] borrow some log-structured ideas to reduce disk seeks (and they have nothing to do with fractals).Especially in pages on the interior of the tree, keys only need to provide enough information to act as boundaries between key ranges. Packing more keys into a page allows the tree to have a higher branching factor, and thus fewer levels.

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Foundations foundation storage Systems System

已有 1 人评分论坛币 学术水平 热心指数 信用等级 收起 理由
经管之家编辑部 + 100 + 3 + 3 + 3 精彩帖子

总评分: 论坛币 + 100  学术水平 + 3  热心指数 + 3  信用等级 + 3   查看全部评分

本帖被以下文库推荐

为你点赞!

使用道具

藤椅
珍惜点滴 学生认证  发表于 2019-3-21 11:32:18 |只看作者 |坛友微信交流群

感谢分享 点赞!

使用道具

板凳
artra2012 在职认证  发表于 2019-3-21 11:41:06 |只看作者 |坛友微信交流群
为您点赞!!!

使用道具

报纸
充实每一天 发表于 2019-3-21 14:44:58 来自手机 |只看作者 |坛友微信交流群
已点赞~

使用道具

地板
从1万到一亿 在职认证  发表于 2019-3-21 18:10:49 |只看作者 |坛友微信交流群
感谢分享!点赞!

使用道具

7
sulight 学生认证  发表于 2019-3-21 21:00:15 |只看作者 |坛友微信交流群
谢谢分享,
内容很好!

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加JingGuanBbs
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-26 10:30