为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本】: 8
【操作系统】:linux
【CPU】:
【问题描述】*:数据表大概有800万左右,分页查询需要关联一些其他的表查询,导致分页查询很慢(sql示例:select id,name,age
from "MSZS".p_test1 ps
where exists(select 1 from "MSZS".test2 op where op.pid=ps.pid and op.live_card_status in('正常','待处理') and op.temp_addr_code='330212'))-------test1表大小十万,test2表800万左右,该建索引都建了,还是很慢(数据刚刚由mysql迁移过来)
这条sql最终返回多少条数据。
以及执行计划发出来
op.live_card_status、op.temp_addr_code可以建立低基数字段位图索引吧
--创建索引
create index idx_test2_dmtest on "MSZS".test2(temp_addr_code,live_card_status,pid);
--修改SQL
select ps.id,ps.name,ps.age
from "MSZS".p_test1 ps
inner join
(select pid from "MSZS".test2 op where op.live_card_status in('正常','待处理') and op.temp_addr_code='330212' group by pid) t
on t.pid=ps.pid;
这样处理看快不快
看一下执行计划,另外如果统计信息未收集的话可以先收集一下统计信息。