2016-06-01 114 views
0
SELECT * 
FROM t1, t2 , t3 
WHERE t1.row_id = t2.invoice_id(+) 
and t2.voi_id = t3.row_id(+) 
and type = 'Dec' 
order by 1 

我有3個指標,一個是在加入每一列,但似乎解釋計劃使用對錶進行全表掃描,而不使用索引:外連接和使用Oracle的索引

計劃

1 Every row in the table t1 is read. 
2 The rows were sorted to support the join at step 5. 
3 Every row in the table t2 is read. 
4 The rows were sorted to support the join at step 5. 
5 Join the sorted results sets provided from steps 2, 4. 
6 Rows were returned by the SELECT statement. 
+2

在Oracle決定使用索引之前,表中需要有足夠的行才能使用索引。 – Glenn

+0

您可能想嘗試使用Oracle提示來查看它是否更改了解釋計劃 - SELECT/* + INDEX(t1 t1_index_name_here)*/*從t1,t2,t3 ... –

+0

如果標準解釋計劃格式被使用。運行'select select * ...;'然後'select * from table(dbms_xplan.display);'並將* entire *輸出添加到問題中。 –

回答

0

這取決於表的行數和大小。在你的查詢中,所有的行t1都會被提取(因爲使用了左連接,並且來自t1的type ='Dec'的所有行將被顯示)。這就是爲什麼TABLE ACCESS FULL到表t1是正常的。

如果行數在T1 t2中超過20-30%的行數(%取決於T2的大小)也TABLE ACCESS FULL到t2和他們哈希聯接是正常的情況。