暂无图片
openGauss列式存储性能较低?
我来答
分享
啦啦啦
2024-11-26
openGauss列式存储性能较低?

CREATE TABLE event_log(
......
)
with (orientation=column)
PARTITION BY RANGE (time_stamp) (
PARTITION el_less_than_1731945600 VALUES LESS THAN (1731945600),
PARTITION el_less_than_1732032000 VALUES LESS THAN (1732032000),
PARTITION el_less_than_maxvalue VALUES LESS THAN (MAXVALUE)
);
建立了张列式存储表,数据量4kw+,单表部分字段简单查询毫秒级,但是一加上排序就得10多秒,想对排序字段添加索引又报错说不允许添加:SQL 错误 [0A000]: [..61.90:57412/..60.108:5432] ERROR: Global partition index does not support column store.

想请教下这种情况如何处理,排序也是常用业务,一排序就性能大低,聚合查询时也很慢,请问是我打开方式不对吗,虚心请教

我来答
添加附件
收藏
分享
问题补充
3条回答
默认
最新
啦啦啦

补充说明,我后面重建了不带分区的相同结构的表,数据量也一致均为4kw+,对排序字段创建了索引、局部聚簇,排序效率仍然没有提升,explain PERFORMANCE查看没有命中索引

--分析查询
explain PERFORMANCE
SELECT id,src_ip, original_ip, src_host_identity, src_ip_high, src_ip_low, src_port, dest_ip, dst_host_identity, dest_ip_high, dest_ip_low, dest_port, ip_version, src_mac, dest_mac, proto
FROM event_log_cxd_with_index
where src_ip like '%0%' and proto = 'TCP'
ORDER BY time_stamp DESC
LIMIT 20;
--打印结果
Row Adapter (cost=19922333.72..19922333.72 rows=20 width=327) (actual time=27800.910..27800.913 rows=20 loops=1)
Output: id, src_ip, original_ip, src_host_identity, src_ip_high, src_ip_low, src_port, dest_ip, dst_host_identity, dest_ip_high, dest_ip_low, dest_port, ip_version, src_mac, dest_mac, proto, time_stamp
(CPU: ex c/r=180029889312447, ex row=20, ex cyc=3600597786248940, inc cyc=3979608079471620)
-> Vector Limit (cost=19922333.67..19922333.72 rows=20 width=327) (actual time=27800.901..27800.901 rows=20 loops=1)
Output: id, src_ip, original_ip, src_host_identity, src_ip_high, src_ip_low, src_port, dest_ip, dst_host_identity, dest_ip_high, dest_ip_low, dest_port, ip_version, src_mac, dest_mac, proto, time_stamp
(CPU: ex c/r=9475257332860, ex row=20, ex cyc=189505146657200, inc cyc=379010293222680)
-> Vector Sort (cost=19922333.67..19947237.45 rows=9961511 width=327) (actual time=27800.895..27800.895 rows=20 loops=1)
Output: id, src_ip, original_ip, src_host_identity, src_ip_high, src_ip_low, src_port, dest_ip, dst_host_identity, dest_ip_high, dest_ip_low, dest_port, ip_version, src_mac, dest_mac, proto, time_stamp
Sort Key: event_log_cxd_with_index.time_stamp DESC
Sort Method: top-N heapsort Memory: 21kB
(Buffers: shared hit=14120)
(CPU: ex c/r=-799311578134, ex row=9701074, ex cyc=-7754180768536294400, inc cyc=189505146565480)
-> CStore Scan on public.event_log_cxd_with_index (cost=0.00..19657261.44 rows=9961511 width=327) (actual time=28.153..19046.583 rows=9701074 loops=1)
Output: id, src_ip, original_ip, src_host_identity, src_ip_high, src_ip_low, src_port, dest_ip, dst_host_identity, dest_ip_high, dest_ip_low, dest_port, ip_version, src_mac, dest_mac, proto, time_stamp
Filter: (((event_log_cxd_with_index.src_ip)::text ~~ '%0%'::text) AND ((event_log_cxd_with_index.proto)::text = 'TCP'::text))
Rows Removed by Filter: 32275833
(Buffers: shared hit=14120)
(CPU: ex c/r=0, ex row=0, ex cyc=7754370273682860032, inc cyc=7754370273682860032)
Total runtime: 27857.006 ms

暂无图片 评论
暂无图片 有用 0
打赏 0
啦啦啦
上传附件:event_log.txt
暂无图片 评论
暂无图片 有用 0
打赏 0
漫步者

列存上是不允许创建全局索引的,可以创建基于每个分区的局部索引;列存是非常适合做聚合的,尤其是少量字段的情况下,你要特别注意查询消除分区,跨分区的检索要慢很多,毕竟扫描的数据块也多。
CREATE TABLE event_log (
id int,
message VARCHAR(100),
time_stamp TIMESTAMP
)
WITH (ORIENTATION = COLUMN)
PARTITION BY RANGE (time_stamp) (
PARTITION p1 VALUES LESS THAN (‘2002-09-10 00:00:00’::TIMESTAMP),
PARTITION p2 VALUES LESS THAN (‘2002-09-11 08:00:00’::TIMESTAMP),
PARTITION p_other VALUES LESS THAN (MAXVALUE)
);

CREATE INDEX idx_event_log_timestamp ON event_log(time_stamp) local;

testdb=# \d+ event_log
Table “public.event_log”
Column | Type | Modifiers | Storage | Stats target | Description
------------±----------------------------±----------±---------±-------------±------------
id | integer | | plain | |
message | character varying(100) | | extended | |
time_stamp | timestamp without time zone | | plain | |
Indexes:
“idx_event_log_timestamp” psort (time_stamp) LOCAL TABLESPACE pg_default
Partition By RANGE(time_stamp)
Number of partitions: 3 (View pg_partition to check each partition range.)
Has OIDs: no
Options: orientation=column, compression=low

暂无图片 评论
暂无图片 有用 0
打赏 0
啦啦啦
题主
2024-11-27
您好 1、聚合查询效率确实也是比较高的,4kw+数据量少字段聚合10秒内都能查出 2、试过对带分区的列存表添加local索引,我创建索引后,对time_stamp排序仍然需要近20秒;也试过复制一张不指定分区的新表,对time_stamp添加索引后进行查询并排序,一样的查询语句仍然需要近20秒,非常耗时;请问目前还有什么可优化的空间吗
回答交流
Markdown


请输入正文
提交
相关推荐
openGauss社区签署的CLA 协议是什么?
回答 3
操作步骤可参考链接中的:提交issue?https://www.bilibili.com/video/BV1mU4y1z7xi/提交PR?https://www.bilibili.com/video/
opengauss的字段值,有办法改参数设为大小写不敏感吗
回答 2
MySQL兼容性下,字段值大小写敏感建表时使用如下选项:utf8mb4generalci/utf8mb4bin
麒麟v10安装openGauss提示rdtscp missing
回答 2
我看cpu应该是支持的,可能是虚拟机不支持,问了网络管理员,说创建虚机的时候并没有什么接触的操作;网上也有说更新内核,这种方法靠谱吗?
可以把现有的postgresql数据库,转到华为的gauss吗?
回答 4
可以,opengauss的pg版本9.2.4,分区表(pg中继承分区)、部分数据类型(时间类型、二进制)不一样。
opengauss failed to connect Unknown:7654
回答 6
这个是opengauss官网的资源获取,https://docsopengauss.osinfra.cn/zh/docs/6.0.0RC1/docs/Appendix/openGauss%E8%B5%
openGauss 与 postgresql在关键技术有什么区别?
回答 1
可参考,欢迎补充:
哪位老师有 roW_number() over(partition by) 的用法?
回答 2
拆分来看rownumber()为每行数据自动生成序列PARTITIONBY按照某列分组ORDERBY按照你前面PARTITIONBY定义的组进行排序PARTITIONBY可省略
哪里有华为相关数据库(openGauss、GaussDB)的认证考试?
回答 1
你可以参考下:https://www.modb.pro/db/34156
Ubuntu系统20.04可以安装opengauss吗?
回答 3
在执行 gsgucreload 命令时,OpenGauss报告它无法找到静态配置文件。这个错误信息提示:“realpath(/usr/local/opengauss/bin/clu
mysql迁移openGauss的方法
回答 3
已采纳
MTKhttps://www.mogdb.io/mtk/