劳烦各位帮忙优化一下SQL和表。非常感谢
informix 7.31用下面的sql运行的时间超级的长。
请问各位,如何优化index和这个sql。
非常感谢。
select sum(a.amount)from table1 wherebumen in (select bmdm from zhongjian:report_bm
where bmz = "******")
and year(deal_date) = "2011"
and deal_date <= "2012-03-31 00:00:00"
and (type= "6" or type ="3" or type = "4" or = "7")
report_bm这个表中的数据就10几条。
table1加索引没?
有没有该SQL的执行计划? and year(deal_date) = "2011"
and deal_date <= "2012-03-31 00:00:00"
这两个条件重复了,可以试试deal_date < "2011-01-01 00:00:00" and deal_date >= "2011-01-01 00:00:00",在(bumen,deal_date)上建个复合索引
如果唯一度不大话,就没有办法了。
页:
[1]