注册

大数据量查询优化

momo 2023/04/23 1412 8 已解决

为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本】: dm8
【操作系统】:centos7
【CPU】:
【问题描述】*:
现在有两张表:icc_contacts和icc_contacts_group_bind,其中icc_contacts大概有300多万的数据,icc_contacts_group_bind大概有400多万的数据。

icc_contacts表的索引如下:

  1. code有一个二级索引,排序是ASC
  2. create_time有一个二级索引,排序是ASC
  3. name,types,is_virtual组成一个联合索引
  4. id有一个唯一索引

icc_contacts_group_bind的索引如下:

  1. group_id,contacts_id 组成一个唯一索引。

执行sql如下:

select t0.id ,t0.code,t0.create_time,t0.group_ids,t0.types,t0.is_virtual,t0.name,t1.group_id from icc_contacts t0 left join icc_contacts_group_bind t1 on t0.id=t1.contacts_id where t0.types=0 and t0.is_virtual=0 order by t0.code desc fetch first 10 rows only;

上面sql的执行时间是9s左右,执行计划如下图所示:
image.png

尝试将排序从t0.code降序调整为t0.code升序排序,效果不明显。
尝试调整HJ_BUF_SIZE的大小为300,也没有效果
只有减少查询的列,只保留t0.id和t1.group_id后,执行时间减少到6.2秒左右。
想请教下各位大佬还有没有其他的优化手段,

回答 0
暂无回答
扫一扫
联系客服