我試圖讓我的查詢儘可能快地運行,但是我正努力讓它在5秒以內。oracle查詢的優化
我想這是因爲我引用兩個相連的數據庫
這裏是我的查詢
select column2, column3, column4
from [email protected]
where column1 in (
select distinct column2
from [email protected]
where column3 > 0
)
order by column1
有沒有辦法來優化這個查詢了嗎?
我一直在使用join
嘗試,但它似乎使查詢運行較長
在此先感謝
編輯
進一步調查DRIVING_SITE
使它像這樣運行
select /*+ DRIVING_SITE(table1) */ t1.column2, t1.column3, t1.column4
from [email protected] t1, [email protected] t2
WHERE t2.column3 > 0
但是,只要我將distinct column2
在它使它運行非常緩慢
一個綜合指數。 http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/sql_elements006.htm#SQLRF50704 –
你不需要'IN'(SELECT ...)裏的'distinct' –
什麼你有2張桌子上的索引嗎? –