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的原因吗,数据量大概有几十万条谁能帮忙解释一下问题原因,谢了!

解决方案 »

  1.   

    就这条sql本身而言,如果数据量大了,sql中的哪些部分会影响处理速度
      

  2.   

    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