Use of Indexes Against Views (179)

tsinglee發表於2007-11-11

Oracle determines whether to use indexes for a query against a view by transforming
the original query when merging it with the view’s defining query.

In all possible cases, Oracle merges a query against a view with the view’s defining
query and those of any underlying views. Oracle optimizes the merged query as if you
issued the query without referencing the views. Therefore, Oracle can use indexes on
any referenced base table columns, whether the columns are referenced in the view
definition or in the user query against the view.

In some cases, Oracle cannot merge the view definition with the user-issued query. In
such cases, Oracle may not use all indexes on referenced columns.

檢視中使用索引
1. 當 Oracle 整合使用者提交的查詢語句與其中所引用檢視的定義語句並對整合結果進行轉化時,將決定此查詢如何使用索引.
2. Oracle 會盡可能地將使用者查詢及其中所引用檢視的定義查詢進行整合.Oracle 將最佳化整合後的語句,
就如同使用者提交的語句中沒有引用檢視一樣.因此,無論一列是被檢視的定義引用,還是被使用者提交的查詢引用,
Oracle 都可以使用建於基表列上的索引.
3. 有些情況下,Oracle 無法將使用者查詢與其中所引用檢視的定義查詢進行整合.此時 Oracle 可能無法使用全部被引用列上的索引.

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10599713/viewspace-981770/,如需轉載,請註明出處,否則將追究法律責任。

相關文章