I know how to implement btree in memory, but not clear about how to store btree in disc. I think there are two major difference:
我知道如何在内存中实现btree,但不清楚如何在光盘中存储btree。我认为有两个主要区别:
- Conversion between memory pointer and disc address, see this post.
- 内存指针和光盘地址之间的转换,请参阅此文章。
- How to split page when insert new k/v item? It is very easy to implement in memory.
- 插入新的k / v项目时如何拆分页面?它很容易在内存中实现。
Thanks
谢谢
2 个解决方案
#1
4
it all depends on DBMS you use. If you wanna know how it is implemented in MS SQL Server, things to read about are:
这一切都取决于您使用的DBMS。如果您想知道它是如何在MS SQL Server中实现的,那么要阅读的内容是:
- Pages (I guess they are in almost all modern DBMS's) - in SQL Server they are 8Kb. Database file is composed from pages.
- 页面(我猜它们几乎都在现代DBMS中) - 在SQL Server中它们是8Kb。数据库文件由页面组成。
- Extents - logical groups of 8 continous pages
- 范围 - 8个连续页面的逻辑组
- (S)GAM - (Shared) Global Allocation Map. Bitmap containing information about free and occupied extents. This is one of the first pages on database file.
- (S)GAM - (共享)全球分配图。包含有关空闲和占用范围的信息的位图。这是数据库文件的第一页。
- IAM - Index Allocation Map. You can find out which index/heap is stored in which extents. Having this information, you can get place in the file where index/heap is stored.
- IAM - 索引分配图。您可以找出哪个索引/堆存储在哪个范围内。有了这些信息,您就可以进入存储索引/堆的文件中。
Using IAM and GAM (or SGAM) you can split page - just move part of the page (which is supposed to be overflowed) to the another page on file.
使用IAM和GAM(或SGAM),您可以拆分页面 - 只需将页面的一部分(应该溢出)移动到文件中的另一个页面。
IAM and GAM are also answers to your first question.
IAM和GAM也是您第一个问题的答案。
Most of these names are taken from MS SQL Server but I'm pretty sure, that in other DBMS's it is solved quite similar.
这些名称中的大部分来自MS SQL Server,但我很确定,在其他DBMS中,它的解决方式非常相似。
Hope it helps.
希望能帮助到你。
#2
1
My recommendation is to have a look at the book Database System Implementation"
我的建议是看看“数据库系统实施”一书“
Chapter 2 "data storage" and chapter 3 "representing data elements" wil give you some hints about this problem.
第2章“数据存储”和第3章“代表数据元素”将为您提供有关此问题的一些提示。
Chapter 4 index structures has a section on Btrees
第4章索引结构有一节关于Btrees
It's the best source of information I have found so far on this topic.
这是迄今为止我在这个主题上找到的最好的信息来源。
#1
4
it all depends on DBMS you use. If you wanna know how it is implemented in MS SQL Server, things to read about are:
这一切都取决于您使用的DBMS。如果您想知道它是如何在MS SQL Server中实现的,那么要阅读的内容是:
- Pages (I guess they are in almost all modern DBMS's) - in SQL Server they are 8Kb. Database file is composed from pages.
- 页面(我猜它们几乎都在现代DBMS中) - 在SQL Server中它们是8Kb。数据库文件由页面组成。
- Extents - logical groups of 8 continous pages
- 范围 - 8个连续页面的逻辑组
- (S)GAM - (Shared) Global Allocation Map. Bitmap containing information about free and occupied extents. This is one of the first pages on database file.
- (S)GAM - (共享)全球分配图。包含有关空闲和占用范围的信息的位图。这是数据库文件的第一页。
- IAM - Index Allocation Map. You can find out which index/heap is stored in which extents. Having this information, you can get place in the file where index/heap is stored.
- IAM - 索引分配图。您可以找出哪个索引/堆存储在哪个范围内。有了这些信息,您就可以进入存储索引/堆的文件中。
Using IAM and GAM (or SGAM) you can split page - just move part of the page (which is supposed to be overflowed) to the another page on file.
使用IAM和GAM(或SGAM),您可以拆分页面 - 只需将页面的一部分(应该溢出)移动到文件中的另一个页面。
IAM and GAM are also answers to your first question.
IAM和GAM也是您第一个问题的答案。
Most of these names are taken from MS SQL Server but I'm pretty sure, that in other DBMS's it is solved quite similar.
这些名称中的大部分来自MS SQL Server,但我很确定,在其他DBMS中,它的解决方式非常相似。
Hope it helps.
希望能帮助到你。
#2
1
My recommendation is to have a look at the book Database System Implementation"
我的建议是看看“数据库系统实施”一书“
Chapter 2 "data storage" and chapter 3 "representing data elements" wil give you some hints about this problem.
第2章“数据存储”和第3章“代表数据元素”将为您提供有关此问题的一些提示。
Chapter 4 index structures has a section on Btrees
第4章索引结构有一节关于Btrees
It's the best source of information I have found so far on this topic.
这是迄今为止我在这个主题上找到的最好的信息来源。