tableA yhdm
tableB yhdm
分别建立索引看看!

解决方案 »

  1.   

    --try:select a.yhlb,a.no from (select yhlb,count(1) no from tablea group by yhlb) a,tableb b
    where a.yhdm=b.yhdm;
      

  2.   

    to ORARichard(没钱的日子......) 
    你写的不对吧,不是统计tablea的用户数,而是tableb的表数
      

  3.   

    select b.yhlb,count(b.*) from tableB b group by b.yhlb
      

  4.   

    select a.yhlb, count(a.yhdm) from tableA a, tableB b where a.yhdm=b.yhdm
      group by a.yhlb
      

  5.   

    在tableA和tableB上按yhdm建立索引,然后再这么写select a.yhlb, count(1) from tableA a, tableB b where a.yhdm=b.yhdm
      group by a.yhlb速度应该可以提高到10秒以内,你试试。
      

  6.   


      a,b表上yhdm都建上索引.
    然后a.yhlb上也建上索引.保证飞快
      

  7.   

    这种简单的交联SQL,本身优化余地很小。楼主,你如果tableB上记录yhlb,再yhlb 上建立索引,将会有质的飞跃:)
      

  8.   

    to  hippie1024(痞子) 
    你如果tableB上记录yhlb??
    记录yhlb是啥意思?俺是菜鸟
      

  9.   

    我的意思就是
    tableB上加一列yhlb
    把"用户类别"每次记在"tableB,用户的电表"上虽然从设计角度讲有数据冗余,不过可以解决你这种查询的效率问题
    怎么权衡就在于你自己了