100w的数据量 查一下要几乎1分钟 不可想象 怎么优化下啊?楼主菜鸟
select case
         when a.type = '1' then
          '存款'
         when a.type = '2' then
          '存款'
         when a.type = '3' then
          '贷款'
         when a.type = '4' then
          '贷款'
         when a.type = '5' then
          '贷款'
         when a.type = '6' then
          '贷款'
         else
          '无数据'
       end as type,
       a.begin_avg,
       a.org_id,
       b.org_name,
       a.manager_id,
       c.group_name as manager_name,
       d.cons_desc,
       a.account_no,
       a.currency_code,
       a.ratio,
       kmh,
       a.customer_id,
       f.customer_name,
       case
         when e.is_sx = '2' then
          '重点'
         else
          '非重点'
       end as is_sx,
       a.Acc_typ,
       a.Store,
       a.amass,
       a.bal_avg,
       a.balance
  from asses_jymgr_mx a, bank_list b,
 outer std_group c,
 outer d_cons d,
 outer customer_list_gj e,
 outer customer_list f
 where a.org_id = b.org_id
   and a.manager_id = c.group_id
   and a.manager_cons = d.cons_id
   and a.customer_id = e.customer_id
   and a.customer_id = f.customer_id
   and a.year = 2012
   and a.month = 11
   and a.acc_typ = '1'

解决方案 »

  1.   

    先把A表和E表做关联加入条件,放在WITH里面,然后在关联其他表进行查询或者,你试试把E表放在A表下面试试。
      from asses_jymgr_mx a,
     outer customer_list_gj e,
     bank_list b,
     outer std_group c,
     outer d_cons d,
     outer customer_list f
     where a.org_id = b.org_id
       and a.year = 2012
       and a.month = 11
       and a.acc_typ = '1'
       and a.customer_id = e.customer_id
       and a.manager_id = c.group_id
       and a.manager_cons = d.cons_id
       and a.customer_id = f.customer_id
      

  2.   

      在众多的 夺标联合查询中 以上这些 观点 我不是 很同意 ,你可以 用 left join (左外连接)查询效率会更高一些,你是在 难以 决断 那个效率 高 你 不行用10万条 数据测试一下,看看那个 花的时间短 。
    具体的 sql 我也就 不写了 ,给你 个思路。
      

  3.   

    建议楼主把 2个表的表结构和数据量都发一下 ,sql 涉及的东西比较多。
      

  4.   

      and a.year = 2012
       and a.month = 11
       and a.acc_typ = '1' 这三条提前 看看year 和month 是数字类型吗, 如果是字符串 的话加上单引号会快的。  a 表是100w b表有多少数据?