=# SELECT relname AS name, sotdsize AS size, sotdtoastsize AS toast, sotdadditionalsize AS other
FROM gp_toolkit.gp_size_of_table_disk as sotd, pg_class
WHERE sotd.sotdoid=pg_class.oid ORDERBY relname;
name | size | toast | other
---------------------------+----------+--------+-------
comm_ne_test_mac |0|0|0
generationstrategytable |262144|0|0
old_t_npa_ctn_moc_busi |62816256|294912|0
old_t_npa_ctn_moc_card |91947008|294912|0
old_t_npa_ctn_moc_ethserv |43483136|294912|0(5 rows)
查看索引占用空间大小
=# SELECT soisize, relname as indexname
FROM pg_class, gp_toolkit.gp_size_of_index
WHERE pg_class.oid=gp_size_of_index.soioid AND pg_class.relkind='i';
soisize | indexname
---------+-------------------------------557056| t_npa_mark_style_pkey
557056| t_npa_mark_style_content_pkey
294912| t_npa_operator_log_pkey
557056| t_npa_periodmark_pkey
557056|t_npa_drill_content_pkey(5 rows)
建表模板
drop table if exists rpt.rpt_bill_m ;
create table rpt.rpt_bill_m(
user_id SERIAL,----自增序列
acct_month varchar(6),
bill_fee numeric(16,2),
user_info text
)WITH(
appendonly=true,-- 对于压缩表跟列存储来说,前提必须是appendonly表
orientation=column,-- 列存 row
compresstype=zlib,-- 压缩格式 --QUICKLZCOMPRESSLEVEL=5,-- 压缩等级 0--9--1 压缩低查询快
OIDS=FALSE)DISTRIBUTEDBY(user_id)-- 分布键
PARTITIONBYLIST("acct_month")--分区键(PARTITION p_201810 VALUES('201810'),PARTITION p_201811 VALUES('201811'),PARTITION p_201812 VALUES('201812'),default partition other --容错没有分区键在此表
/* PARTITION p_20170801 START('20170801'::DATE) END ('20170831'::DATE)
EVERY ('1 month'::INTERVAL) */);
comment on column rpt.rpt_bill_m.user_info is '员工备注信息';-- 注解