這幾天在開(kāi)發(fā)一個(gè)模塊的時(shí)候,遇到一個(gè)棘手的問(wèn)題:海量數(shù)據(jù)的查詢效率問(wèn)題,在下面的sql語(yǔ)句中,sf02表的數(shù)據(jù)在七千萬(wàn)左右,sf01表的數(shù)據(jù)在三千萬(wàn)左右,并且兩個(gè)表有關(guān)聯(lián):
select a.tcol2, a.departcode, a.sendtime, sum(a.mainamount) mainamount
from sf02 a
where a.ksdm = '11019204'
and exists
(select policyno
from sf01 b
where b.businessnature = '531'
union all select policyno from sf01 b where b.businessnature = '532'
and a.policyno = b.policyno)
and (a.kindcode = 'R21' or a.kindcode = 'R29')
and a.insert_time <= to_date('2011-09-05', 'yyyy-MM-dd')
and a.insert_time >= to_date('2000-08-25', 'yyyy-MM-dd')
group by a.tcol2, a.departcode, a.sendtime
由于數(shù)據(jù)庫(kù)是分公司的,創(chuàng)建臨時(shí)表不是太好使,這個(gè)問(wèn)題一直沒(méi)有太好的解決辦法,不知道各位有沒(méi)有好的思路,希望各位留下寶貴的意見(jiàn),由于這個(gè)帖子放在提問(wèn)區(qū)一直沒(méi)有人瀏覽,不得已放在首頁(yè),還請(qǐng)blogJava對(duì)該帖放行,非常感謝。