全部博文(136)
分类: Oracle
2008-06-02 09:03:57
SQL>
create table test_index as select * from dba_objects; 表已创建。 SQL>
create index ind_test_index1 on test_index(OWNER, OBJECT_NAME,
OBJECT_ID); 索引已创建。 |
SQL>
explain plan for 2
select * from test_index where object_name='adf'; 已解释。 SQL>
@?\rdbms\admin\utlxpls PLAN_TABLE_OUTPUT -------------------------------------------------------------------- -------------------------------------------------------------------- |
Id | Operation |
Name | Rows | Bytes | Cost | -------------------------------------------------------------------- | 0 | SELECT STATEMENT | | |
| | |* 1 |
TABLE ACCESS FULL | TEST_INDEX |
| |
| -------------------------------------------------------------------- Predicate
Information (identified by operation id): --------------------------------------------------- PLAN_TABLE_OUTPUT -------------------------------------------------------------------- 1 -
filter("TEST_INDEX"."OBJECT_NAME"='adf') Note:
rule based optimization 已选择14行。 |
2
select/*+ index (test_index ind_test_index1) */ * from
test_index where object_name='adf'; 已解释。 SQL>
@?\rdbms\admin\utlxpls PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- |
Id | Operation |
Name | Rows | Bytes | Cost | -------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 329 | 58233 | 34 | | 1 |
TABLE ACCESS BY INDEX ROWID| TEST_INDEX |
329 | 58233 | 34
| |* 2 |
INDEX FULL SCAN | IND_TEST_INDEX1 |
329 | | 26 | -------------------------------------------------------------------------------- Predicate
Information (identified by operation id): --------------------------------------------------- PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- 2 -
access("TEST_INDEX"."OBJECT_NAME"='adf')
filter("TEST_INDEX"."OBJECT_NAME"='adf') Note:
cpu costing is off 已选择16行。 |
SQL>
analyze table test_index compute statistics; 表已分析。 SQL>
explain plan for 2
select * from test_index where object_name='adf'; 已解释。 SQL>
@?\rdbms\admin\utlxpls PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- |
Id | Operation | Name | Rows | Bytes | Cost | -------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 2 |
172 | 31
| | 1 |
TABLE ACCESS BY INDEX ROWID| TEST_INDEX |
2 | 172 | 31 | |* 2 |
INDEX SKIP SCAN | IND_TEST_INDEX1 |
1 | | 30 | -------------------------------------------------------------------------------- Predicate
Information (identified by operation id): --------------------------------------------------- PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- 2 -
access("TEST_INDEX"."OBJECT_NAME"='adf')
filter("TEST_INDEX"."OBJECT_NAME"='adf') Note:
cpu costing is off 已选择16行。 |