Gauss HTAP特性
【摘要】 --整表设置或者取消alter table table_name colview;alter table table_name nocolview;--指定部分列,或者排除部分列alter table table_name colview(column1,column2);alter table table_name colview nocolview(column1,column2);--...
--整表设置或者取消
alter table table_name colview;
alter table table_name nocolview;
--指定部分列,或者排除部分列
alter table table_name colview(column1,column2);
alter table table_name colview nocolview(column1,column2);
--分区表
alter table table_name modify partition partition_name colview/nocolview;
--当前对于分区只能在表维度设定加载具体列,各分区表遵从,无法单独按分区设置
--参考消耗的内存情况,行数如果没有就做下表分析analyze tablename
SELECT (select n.nspname from pg_class c,pg_namespace n where c.oid=reloid and c.relnamespace=n.oid),
b.col "列存", --列内存
round(pg_relation_size(a.reloid) / 1024 / 1024, 2) "行存", --行存磁盘
round(pg_indexes_size(a.reloid) / 1024 / 1024, 2) "索存", --行索引磁盘
decode(imcvispart, TRUE, round(pg_partition_size(a.parentoid, a.reloid) / 1024 / 1024, 2)) "分区", --分区行磁盘"
CASE WHEN imcvispart THEN (SELECT reltuples FROM pg_partition WHERE parentid = parentoid AND OID = reloid)
ELSE (select reltuples from pg_class where oid=reloid) END "约行数",
a.*
FROM gs_imcv a,
(SELECT REPLACE(contextname, 'IMCUDescContext', '') OID,
round(SUM(usedsize) / 1024 / 1024, 2) col
FROM pg_shared_memory_detail()
WHERE contextname LIKE 'IMCUDescContext%'
GROUP BY contextname) b
WHERE a.reloid ::text = b.oid
order by parentoid,reloid ;
--内存使用情况
select * from pv_total_memory_detail() where memorytype='htap_used_memory';
select * from pv_total_memory_detail() where memorytype='dynamic_used_memory';
--IMCV相关操作以及视图
select * from gs_imcv; --提供了所有IMCV表的元信息
select * from gs_imcv_status; --显示数据库中IMCV表的状态信息(rowgroup_num 加载的行组数,cu_num_in_mem 内存中的IMCU数量),该视图同时存在于PG_CATALOG和SYS Schema下
select * from gs_imcv_flush(oid);--对数据库中指定的IMCV表立即进行一次重建,并显示重建的结果
select * from gs_htap_tmu_data(oid); --查看实时事务单元TMU中的活跃事务数据,当rowgroup_id为0时,返回表中所有活跃事务数据;当rowgroup_id非0时,返回表中指定行组中的活跃事务数据(TMU:Transaction Metadata Unit),需系统管理员或运维管理员权限
select * from gs_imcu_slot_status;--IMCV表下的IMCU对应的缓存slot信息
--设置走那种模式
set htap_router_mode='auto';--根据查询请求中的列是否加载到IMCV,以及行列计划代价高低,自动选择行、列、行列混合计划
set htap_router_mode='row';--强制使查询负载选择行存计划
set htap_router_mode='column';--当查询请求中的列加载到IMCV时,无视代价高低,强制执行列存(IMCVScan)计划;若存在未加载到IMCV的列时,执行行存计划
内存中的数据结构理解示意。
1000页划分为一个行组,一个行组相当于一个二维数组,或者一组数组。
1、相同下标的可以横向组成一行数据(执行计划中的Row Adapter),如绿色背景示意。
2、纵向一列就是一列数据,可以实现快速过滤,或者聚合,如红色字体示意
注:ctid是元组标识符,是一个伪列,其格式为(block number,offset number),其中:
block number:表示行所在的物理块(即数据库页面)编号。
offset number:表示行在该物理块内的偏移量,即在同一块内的顺序编号。
数据下标 |
CU0 | CU1 | CU2 | CU3 | TMU |
||
ctid | attr1 | attr2 | attr3 | ||||
RowGroup #0 |
P0 ~ P999 |
1 | (0,0) | x | x | x | 事务中更改的ctid信息 |
2 | (0,1) | x | x | x | |||
··· | ··· | x | x | x | |||
N | (999,0) | x | x | x | |||
RowGroup #1 |
P1000 ~ P1999 |
1 | (1000,0) | x | x | x | 事务中更改的ctid信息 |
2 | (1001,0) | x | x | x | |||
··· | ··· | x | x | x | |||
N | (1999,0) | x | x | x |
【版权声明】本文为华为云社区用户原创内容,未经允许不得转载,如需转载请自行联系原作者进行授权。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
作者其他文章
评论(0)