SQL> conn y / 123
SQL> create table t(i char(10),v number) tablespace test;
SQL> insert into t values('1',10);
SQL> insert into t values('2',20);
SQL> commit;
SQL> select * from t;
I V
---------- ----------
1 10
2 20
|
SQL> create tablespace ind datafile '/oracle/ind.dbf' size 10M ;
SQL> conn y / 123
SQL> create index ti_ind on t(i) tablespace ind ;
|
sql>@$ORACLE_HOME/rdbms/admin/utlxplan.sql
sql>@$ORACLE_HOME/sqlplus/admin/plustrce.sql
SQL>grant PLUSTRACE to public
SQL>set autot traceonly;
|
SQL> select * from t where i='1';
Execution Plan
----------------------------------------------------------
Plan hash value: 2865601831
-------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 25 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| T | 1 | 25 | 2 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | TI_IND | 1 | | 1 (0)| 00:00:01 |
|
SQL> select * from t where i=1;
Execution Plan
----------------------------------------------------------
Plan hash value: 1601196873
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 25 | 7 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| T | 1 | 25 | 7 (0)| 00:00:01 |
|
SQL> select * from t where i<>'3';
Execution Plan
----------------------------------------------------------
Plan hash value: 1601196873
----------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 2 | 50 | 7 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| T | 2 | 50 | 7 (0)| 00:00:01 |
|
SQL> select * from t where i='';
no rows selected
Execution Plan
----------------------------------------------------------
Plan hash value: 1322348184
-----------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 25 | 0 (0)| |
|* 1 | FILTER | | | | | |
| 2 | TABLE ACCESS FULL| T | 2 | 50 | 7 (0)| 00:00:01 |
|
update t set i='A' where v=10;
SQL> select * from t;
I V
---------- ------------
A 10
2 20
|
SQL> select * from t where i='A';
---------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time
-----------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 25 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| T | 1 | 25 | 2 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | TI_IND | 1 | | 1 (0)| 00:00:01 |
----------------------------------------------------------------------
|
SQL> select * from t where i=upper('a');
Execution Plan
------------------------------------------------------------
Plan hash value: 1601196873
-------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 25 | 7 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| T | 1 | 25 | 7 (0)| 00:00:01 |
-----------------------------------------------------------------
|
SQL> show parameter optimizer_index_cost_adj
NAME TYPE VALUE
-------------------- ----------- ------------------------------
optimizer_index_cost_adj integer 100
|
SQL> alter system set optimizer_index_cost_adj=10;
System altered.
|
SQL> select * from t where i=upper('a');
| 0 | SELECT STATEMENT | | 1 | 25 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| T | 1 | 25 | 2 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | TI_IND | 1 | | 1 (0)| 00:00:01 |
|
SQL> show parameter db_file_multiblock_read_count
NAME TYPE VALUE
---------------------- ----------- ------------------------------
db_file_multiblock_read_count integer 128
|
SQL>drop index indexname
|