簡體   English   中英

如何優化以下 SQL 查詢的性能?

[英]How to optimize the performance of the following SQL query?

對於以下查詢,我嘗試使用列 indcont_key_1 和 ind_no 在表 tmp.req_index_cont_t 上創建索引,但優化器仍在執行全表掃描,我不知道如何解決此問題,請指導:

CREATE INDEX tmp.REQ_CONT_T_IDX 
            ON tmp.req_index_cont_t (ind_no, indcont_key_1);

select distinct
            rit.item_no as item_no,
            rit.item_type as item_type,    
            rit.ind_no as ind_no,
            rit.delete_date as req_ind_delete_date,
            indcnt.delete_date as req_ind_cont_delete_date
from
    tmp.req_index_cont_t indcnt,
    tmp.req_index_t rit
where    rit.ind_no             = indcnt.ind_no
    and   indcnt.indcont_key_1 <> 'DN'
    and   rit.ind_state         = 'Approved'
group by    rit.item_no,
            rit.item_type,
            rit.ind_no,
            indcnt.delete_date,
            rit.delete_date ; 

這里沒有足夠的信息來回答你的問題。 為什么您認為全表掃描不是此查詢的最佳選擇? 我假設您對它正在對req_index_cont_t進行全表掃描感到不安,因為那是您放置索引的那個。

作為一個有根據的猜測,我會說這是因為您在選擇列表中有indcnt.delete_date而不是索引。 這意味着 Oracle 將不得不獲取有問題的整行,並決定不使用該索引。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM