MatrixDB Mars存储引擎
Mars存储引擎是MatrixDB自研的存储类型。简单测试下其和Greenplum传统的堆表和列存储表的区别。
--不同存储引擎对比
1、Heap
- 优点:Heap表为传统PostgreSQL数据库提供的存储类型,又称堆表。该类型的表支持大量并发读写、事务、索引等特性。
- 缺点:表压缩低,查询性能较弱。
2、AppendOnly
- 优点:列存储,相较于堆表提供了更高效的I/O和存储,适合于在少量列上计算数据聚集。
- 缺点:不适合数据会被频繁修改的OLTP场景。
3、Mars
- 优点:支持压缩、列存、预聚集,在分析场景中性能极高。
- 缺点:要求数据按顺序插入,并且暂不支持更新和删除。
--性能测试
分别创建三种存储类型的表:
create table t1( id int8 , info text default 'tessssssssssssssssssssssssssssssssssssst', state int default 0, crt_time timestamp default now(), mod_time timestamp default now() ) using mars;create table t2( id int8 , info text default 'tessssssssssssssssssssssssssssssssssssst', state int default 0, crt_time timestamp default now(), mod_time timestamp default now() ) with (appendonly=true);create table t3( id int8, info text default 'tessssssssssssssssssssssssssssssssssssst', state int default 0, crt_time timestamp default now(), mod_time timestamp default now() );
各插入1000万条数据,查看表大小。
压缩性能:
Mars表:
bill=# \dt+ t1List of relationsSchema | Name | Type | Owner | Storage | Size | Description --------+------+-------+-------+---------+--------+-------------public | t1 | table | bill | | 404 MB | (1 row)
AO表:
bill=# \dt+ t2List of relationsSchema | Name | Type | Owner | Storage | Size | Description --------+------+-------+-------+-------------+--------+-------------public | t2 | table | bill | append only | 783 MB | (1 row)
Heap表:
bill=# \dt+ t3List of relationsSchema | Name | Type | Owner | Storage | Size | Description --------+------+-------+-------+---------+--------+-------------public | t3 | table | bill | heap | 965 MB | (1 row)
可以发现三种类型的表压缩比Mars最大,其次是AO表。
点查性能:
vi t1.sql
\set id random(1,10000000) select * from t1 where id=:id;
因为AO表只适合对少量列进行查询的场景,这里主要对比Mars表和Heap表。
pgbench -M prepared -n -r -P 1 -f ./t1.sql -c 8 -j 8 -T 60
Mars表:
transaction type: ./t1.sql scaling factor: 1 query mode: prepared number of clients: 8 number of threads: 8 duration: 60 s number of transactions actually processed: 5784 latency average = 83.017 ms latency stddev = 23.960 ms tps = 96.319501 (including connections establishing) tps = 96.335590 (excluding connections establishing) statement latencies in milliseconds:0.003 \set id random(1,10000000)
Heap表:
transaction type: ./t3.sql scaling factor: 1 query mode: prepared number of clients: 8 number of threads: 8 duration: 60 s number of transactions actually processed: 462 latency average = 1048.816 ms latency stddev = 355.852 ms tps = 7.567875 (including connections establishing) tps = 7.568976 (excluding connections establishing) statement latencies in milliseconds:0.004 \set id random(1,10000000)1048.812 select * from t3 where id=:id;
可以看到Mars表的查询性能相较于堆表提升明显。
通过观察执行计划我们还可以发现:
无论查询的数据是什么,使用Mars表查询的cost是一样的。
再加上前面所说,Mars表不支持更新和删除。我们可以猜测Mars表似乎是对数据做了类似hash之类的处理,保证其查询复杂度为O(1),当然由于MatrixDB尚未开源,这些只是猜测。
postgres=# explain analyze select * from t1 where id = 555555;QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------Gather Motion 2:1 (slice1; segments: 2) (cost=0.00..8714.61 rows=1 width=69) (actual time=32.468..33.044 rows=1 loops=1)-> Custom Scan (MarsSortScan) on t1 (cost=0.00..8714.59 rows=1 width=69) (actual time=6.149..6.270 rows=1 loops=1)Filter: (id = 555555)Planning Time: 0.159 ms(slice0) Executor memory: 22K bytes.(slice1) Executor memory: 39K bytes avg x 2 workers, 39K bytes max (seg0).Memory used: 128000kBOptimizer: Postgres query optimizerExecution Time: 41.219 ms (9 rows)postgres=# explain analyze select * from t1 where id = 5555555;QUERY PLAN --------------------------------------------------------------------------------------------------------------------------Gather Motion 2:1 (slice1; segments: 2) (cost=0.00..8714.61 rows=1 width=69) (actual time=4.130..4.133 rows=1 loops=1)-> Custom Scan (MarsSortScan) on t1 (cost=0.00..8714.59 rows=1 width=69) (actual time=3.665..3.745 rows=1 loops=1)Filter: (id = 5555555)Planning Time: 0.142 ms(slice0) Executor memory: 22K bytes.(slice1) Executor memory: 28K bytes avg x 2 workers, 28K bytes max (seg0).Memory used: 128000kBOptimizer: Postgres query optimizerExecution Time: 5.037 ms (9 rows)postgres=# explain analyze select * from t1 where id = 55555555;QUERY PLAN --------------------------------------------------------------------------------------------------------------------------Gather Motion 2:1 (slice1; segments: 2) (cost=0.00..8714.61 rows=1 width=69) (actual time=1.496..1.497 rows=0 loops=1)-> Custom Scan (MarsSortScan) on t1 (cost=0.00..8714.59 rows=1 width=69) (actual time=1.188..1.189 rows=0 loops=1)Filter: (id = 55555555)Planning Time: 0.149 ms(slice0) Executor memory: 22K bytes.(slice1) Executor memory: 28K bytes avg x 2 workers, 28K bytes max (seg0).Memory used: 128000kBOptimizer: Postgres query optimizerExecution Time: 1.945 ms (9 rows)
MatrixDB - 存储引擎选择与转换
MatrixDB Mars存储引擎相关推荐
- 浅谈MySQL存储引擎-InnoDBMyISAM
浅谈MySQL存储引擎-InnoDB&MyISAM 存储引擎在MySQL的逻辑架构中位于第三层,负责MySQL中的数据的存储和提取.MySQL存储引擎有很多,不同的存储引擎保存数据和索引的方式 ...
- 3种mysql的储存机制_MySQL三种InnoDB、MyISAM和MEMORY存储引擎对比
三种引擎的区别: 事务:InnoDB支持事务,MyISAM和MEMORY两个不支持. 存储限制:InnoDB有64TB的存储限制,MyISAM和MEMORY要跟具体情况而定. 空间使用:InnoDB对 ...
- mysql的存储引擎详解_Mysql存储引擎详解
存储引擎的介绍 关系型数据库表是用来存储和组织信息的数据结构,可以将表理解为由行和列组成的表格. 由于表的类型不同,我们在实际开发过程中,就有可能需要各种各样的表,不同的表就意味着存储不同类型的数据, ...
- 基于持久内存的 单机上亿(128B)QPS -- 持久化 k/v 存储引擎
文章目录 性能数据 设计背景 设计架构 Hash 索引结构 及 PMEM空间管理形态 基本API 及 实现 API 初始化流程 写流程 读流程 删除流程 PMEM Allocator设计 主要组件 空 ...
- 跟着Rocskdb 学 存储引擎:读写链路的代码极致优化
文章目录 1. 读链路 1.1 FileIndexer 1.1.1 LevelDB sst查找实现 1.1.2 Rocksdb FileIndexer实现 1.2 PinnableSlice 减少内存 ...
- 存储引擎 K/V 分离下的index回写问题
前言 近期在做on nvme hash引擎相关的事情,对于非全序的数据集的存储需求,相比于我们传统的LSM或者B-tree的数据结构来说 能够减少很多维护全序上的计算/存储资源.当然我们要保证hash ...
- MyRocks: 为facebool 的社交图谱服务的LSM-tree存储引擎
文章目录 概览 1. UDB 架构 2. UDB 表格式 3. Rocksdb:针对flash存储优化过的第三方库 3.1 Rocksdb架构 3.2 为什么选择Rocksdb 4. MyRocks ...
- 一个简单的程序来使用WiredTiger 存储引擎
前言 WiredTiger 自 mongodb3.0 集成进来之后为mongodb拉回了大量的口碑,从而在mongodb-3.2 版本直接代替了in-memory存储引擎,作为了mongodb的默认存 ...
- BitCask 持久化hash存储引擎 原理介绍
文章目录 前言 引擎背景 引擎原理 1. 磁盘数据结构 2. 内存数据结构 3. 读流程 4. 数据合并 总结 前言 最近工作中部分项目中,对存储引擎的需求希望高性能的写.点查,并不需要Range.这 ...
最新文章
- 在一个公司死磕了5-10年的人,最后都怎么样了?
- linux shell脚本字符串连接符,学习Linux shell脚本中连接字符串的方法
- wince6.0远程控制工具_【创新创效】门架业务主动监测工具和远程控制电源开关...
- PyQt4编程之如何做菜单栏
- Python中的正则表达式(特征匹配)
- 阿里大数据分析与应用(part7)--机器学习平台PAI
- Linux OpenGL 实践篇-2 创建一个窗口
- [Matlab] 无插件导入公式到 Word 中的方法:由 Matlab 导出 MathML 公式,复制到 Word 公式中
- [PHP] 面向对象
- android谷歌反地理,Android反向地理编码显示不出来!
- Error: Some file crunching failed
- 小心被举报!考研复试后不要分享考试内容!
- 恶意程序利用Linksys路由器漏洞在路由器中传播
- 为什么U盘中的文件夹和文件全部变成了快捷方式?
- VIM复制到系统剪切板
- 瞧,工程师绘图最佳实践!
- 中国最懒城市,这里的人不想赚钱,只想躺平
- ADX集团宣布2020年上市计划
- 嵌入式软件工程师就业方向有哪些呢?
- 一份能帮助到你的2021年终总结