列存表限制
- 列存表不支持数组。
- 列存表的数量建议不超过1000个。
- 列存表的表级约束只支持PARTIAL CLUSTER KEY,不支持主外键等表级约束。
- 列存表的字段约束只支持NULL、NOT NULL和DEFAULT常量值。
- 列存表不支持alter命令修改字段约束。
- 列存表支持delta表,受参数enable_delta_store 控制是否开启,受参数deltarow_threshold控制进入delta表的阀值。
列存相关参数
-
cstore_buffers
列存所使用的共享缓冲区的大小,默认值:32768KB。
-
partition_mem_batch
指定缓存个数,为了优化对列存分区表的批量插入,在批量插入过程中会对数据进行缓存后再批量写盘。默认值:256 。
-
partition_max_cache_size
指定数据缓存区大小,为了优化对列存分区表的批量插入,在批量插入过程中会对数据进行缓存后再批量写盘。默认值:2GB。
-
enable_delta_store
为了增强列存单条数据导入的性能和解决磁盘冗余问题,是否需要开启列存delta表功能,与参数DELTAROW_THRESHOLD 配合使用。默认值:off。
建表语法
openGauss 创建普通表默认是未压缩的行存表。
mydb=# \dt
No relations found.
mydb=# create table test_t(id serial primary key ,col1 varchar(8),col2 decimal(6,2),create_time timestamptz not null default now());
NOTICE: CREATE TABLE will create implicit sequence "test_t_id_seq" for serial column "test_t.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "test_t_pkey" for table "test_t"
CREATE TABLE
mydb=# \dt+
List of relations
Schema | Name | Type | Owner | Size | Storage | Description
--------+--------+-------+-------+---------+----------------------------------+-------------
public | test_t | table | omm | 0 bytes | {orientation=row,compression=no} |
(1 row)
mydb=#
创建列存表,需要指定orientation=column,默认压缩级别是low。
mydb=# create table column_t(id serial,col1 varchar(8),col2 decimal(6,2),create_time timestamptz not null default now()) with (orientation=column );
NOTICE: CREATE TABLE will create implicit sequence "column_t_id_seq" for serial column "column_t.id"
CREATE TABLE
mydb=# \dt+
List of relations
Schema | Name | Type | Owner | Size | Storage | Description
--------+----------+-------+-------+---------+--------------------------------------+-------------
public | column_t