這幾天在開發(fā)一個(gè)模塊的時(shí)候,遇到一個(gè)棘手的問題:海量數(shù)據(jù)的查詢效率問題,在下面的sql語句中,sf02表的數(shù)據(jù)在七千萬左右,sf01表的數(shù)據(jù)在三千萬左右,并且兩個(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ù)庫是分公司的,創(chuàng)建臨時(shí)表不是太好使,這個(gè)問題一直沒有太好的解決辦法,不知道各位有沒有好的思路,希望各位留下寶貴的意見,由于這個(gè)帖子放在提問區(qū)一直沒有人瀏覽,不得已放在首頁,還請(qǐng)blogJava對(duì)該帖放行,非常感謝。