Execution Plan image:
FILTER condition that is applied when performing a table access (such as during a FILTER operation) is sometimes implicit. Any FILTER clause condition when no index can be used to assist in the evaluation. Unfortunately, the WHERE performs a TABLE ACCESS BY ROWID does not show up in the plan. When FILTER shows up in a plan, it is usually the result of a missing index or the disabling of an existing index.
The FILTER operation was in a prior example—the CONNECT BY operation example. In the query shown in the following example, the WHERE criteria on the State column is not applied until after the CONNECT BY hierarchy has completed; the resulting rows are filtered to determine which meet the specified State criteria.
select Company_ID, Name
from COMPANY
where State = 'VA'
connect by Parent_Company_ID = prior Company_ID
start with Company_ID = 1;
FILTER
CONNECT BY
INDEX UNIQUE SCAN COMPANY_PK
TABLE ACCESS BY ROWID COMPANY
TABLE ACCESS BY ROWID COMPANY
INDEX RANGE SCAN COMPANY$PARENT
The plan shows that first the COMPANY_PK index is being used to find the root node (Company_ID = 1), the index on the Parent_Company_ID column is used to provide values for queries against the Company_ID column in an iterative fashion. After the hierarchy of Company_ID is complete, the FILTER operation—the WHERE clause related to the State value—is applied. The query does not use the index on the State column, although it is available and the column is used in the WHERE clause.
Execution plan image:
Row operation.
FIRST ROWS uses a cost-based approach for all SQL statements in the session regardless of the presence of statistics and optimizes with a goal of best response time (minimum resource use to return the first row of the result set).
The following statement changes the goal of the cost-based optimizer for your session to best response time:
ALTER SESSION SET OPTIMIZER_MODE = FIRST_ROWS;
Execution Plan image:
Set operation.
Where an index exists on a V$ table, it will normally be used whenever the column is used for an exact lookup. The execution plan reveals that this is so through the special access path FIXED INDEX. For instance, the following query uses the SID index on V$SESSION:
select *
from v$session where sid=171
Rows |
Execution Plan |
1 |
FIXED TABLE FIXED INDEX #1 X$KSUSE |
Remembering that the "index" is not really an Oracle B-tree index and in has more in common with a hash cluster, it’s not surprising to see that the index is disabled if a range scan is attempted:
select *
from v$session where sid<8
Rows |
Execution Plan |
700 |
FIXED TABLE FULL X$KSUSE |
Execution Plan image:
Set operation.
Fixed tables are those not in Oracle’s data dictionary. FIXED TABLE is normally used to optimize V$ and X$ statements. However, join order for a V$ query is determined by the order of tables in the FROM clause. Be careful when using FIXED TABLE because:
Neither the cost-based optimizer nor the rule-based optimizer recognizes the presence of V$ indexes when determining join order or method.
There are never any optimizer statistics held against the V$ or X$ tables and consequently the cost-based optimizer has no information to use to determine the best join order.
© 2024 Quest Software Inc. ALL RIGHTS RESERVED. Terms of Use Privacy Cookie Preference Center