字符串排序查询优化

Viewed 49

建表语句

CREATE TABLE `tbl` (
`a` varchar(64) NULL,
`b` varchar(64) NOT NULL,
`c` varchar(64) NOT NULL,
`d` varchar(20) NOT NULL,
`e` varchar(20) NOT NULL,
 ...

) ENGINE=OLAP
UNIQUE KEY(`a`, `b`, `c`)
DISTRIBUTED BY HASH(`d`, `a`, `c`) BUCKETS 32
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);

查询如下,目前耗时大概在9s左右

select
a, b, c, d, e,....
from tbl
where d = 'SO1'
  and e = 'WO1'
order by a, b, c
limit 5000000, 1000;

前缀索引对于字符串类型的列效果有限
问一下 还有什么办法能够优化这条排序查询

1 Answers
  1. 将这张 Unique 表变为 MOW 表,重新创建一张表,在建表 properties 中加上enable_unique_key_merge_on_write = true 重新查询,看看性能是否有提升

  2. 如果查询还是没提升,那么请提交个 profile 来,set enable_profile = true; 同一个session执行sql,从webui取对应 queryprofile