哪为DBA老大帮忙看看,解释一下问题原因
select distinct kmlb,kmlbm from grht_km a, grdk_pzflb c where c.kmh like a.kmh||'%' and a.kmlb like 'KHCX_%' and c.khh='1234' order by a.kmlb
这条sql一执行,cpu的使用率就到100%,请问为什么啊,是因为这条sql的原因吗,数据量大概有几十万条
谁能帮忙解释一下问题原因,谢了!
------解决方案--------------------得看你的表有没有查询条件里的索引了。
------解决方案--------------------select distinct kmlb, kmlbm
from grht_km a, grdk_pzflb c
where c.kmh like a.kmh || '%' --关联条件不带这么写的,这样子写无论如何都用不到索引或者主键索引
and a.kmlb like 'KHCX_%'
and c.khh = '1234'--这个字段没有建立索引的话,对于C表就是全表查询
order by a.kmlb