MPP架构数据库,通过数据分布策略来避免并行计算期间的资源竞争,通过Sharding机制,使SQL本地化执行,避免跨节点的查询和事务,从而提高事务并行执行的效率,以及并发性能。
- 复制表:每个节点上都复制一份,数据关联时在节点本地完成。
- 一份数据根据某个键值水平拆分到不同的节点上。分布方式:随机,Sharding机制:支持Range、List、Hash
⑴ range根据键值的范围来分布数据
Create table t1(id int, name varchar)
Sharding by range(id)
(sharding s1 values less than(10) sg hg01,
sharding s2 values less than(20) sg hg02);
⑵ list根据键值的列表来分布数据
Create table t2(id int, name varchar)
Sharding by list(id)
(sharding s1 values in(1,3,5,7,9) sg hg01,
sharding s2 values in(2,4,6,8,10) sg hg02);
⑶ hash根据键值哈希值来分布数据
Create table t3(id int, name varchar)
Sharding by hash(id) shardings 2; -- 数据自动分配到两个 sg 上