自研分区

最近更新时间: 2024-06-12 15:06:00

在多分区表情况下,自研分区表性能更好。自研分区表随着分区的增多,性能不能不会下降,在2048个分区的情况下,自研分区表的剪技访问性能是普通分区(范围、列表、散列)表的30倍。 示例: 创建自研分区表(2048个分区):

create table t_time_range
(
  f1 bigint not null, f2 timestamp ,f3 bigint
) 
partition by range (f2) begin (timestamp without time zone '2017-09-01 0:0:0') 
step (interval '1 month') 
partitions (2048) distribute by shard(f1) 
to group default_group;

向分区表中插入数据

select 'insert into t_time_range values(1,'''||startyf||''',1);' from (select ('2017-09-01'::date + (t::text||' months')::interval)::date::text as startyf from generate_series(0,2047) as t) as t;