2023-04-13 monetdb-str类型变长存储-分析

本文详细探讨了MonetDB数据库中str类型数据的存储方式,特别是如何在BAT结构中使用独立的theap文件存储变长数据,并通过tail文件保留偏移量。内容涵盖DML操作、数据分析、查询执行时的访问模式以及对str类型列d2的存储细节分析。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

摘要:

monetdb的列的基本抽象是BAT,但是对于列数据的存储方式, 对于固定长度和不固定长度,使用了不同的存储方式。

固定长度的数据比如int,int64之类的, 直接存储在了数据tail文件。

但是对于不固定长度比如string, 则使用另外一个独立的theap文件存储, tail文件仅保留对于threap的文件的偏移。

本文对str数据类型的存储进行详细的分析

BAT中的数据存储方式说明

Design Overview | MonetDB Docs

https://github.com/MonetDB/MonetDB/blob/master/gdk/gdk.h#L583

The above figure shows what a BAT looks like. It consists of two
columns, called head and tail, such that we have always binary
tuples (BUNs). The overlooking structure is the @strong{BAT
record}.  It points to a heap structure called the @strong{BUN
heap}.  This heap contains the atomic values inside the two
columns. If they are fixed-sized atoms, these atoms reside directly
in the BUN heap. If they are variable-sized atoms (such as string
or polygon), however, the columns has an extra heap for storing
those (such @strong{variable-sized atom heaps} are then referred to
as @strong{Head Heap}s and @strong{Tail Heap}s). The BUN heap then
contains integer byte-offsets (fixed-sized, of course) into a head-
or tail-heap.

DML

create table b(b1 int, b2 varchar(2), primary key(b1)) ;
 
create table a(a1 int, a2 varchar(2), foreign key(a1) references b(b1)) ;
 
create table c(c1 int, c2 varchar(2)) ;
 
create table d(d1 int, d2 varchar(2)) ;

insert into a values(1, 'a1');
 
insert into a values(null, 'a2');
 
insert into a values(3, 'a3');
 
insert into b values(1, 'b1');
 
insert into b values(2, 'b2');
 
insert into b values(3, 'b3');
 
insert into c values(1, 'c1');
 
insert into c values(2, 'c2');
 
insert into c values(null, 'c3');
 
insert into d values(1, 'd1&#
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

悟世者

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值