sys@EBANK>desc test
Name Null? Type
------------------------------------------------------------------------ -------- -------------------------------------------------
OWNER VARCHAR2(30)
OBJECT_NAME VARCHAR2(128)
SUBOBJECT_NAME VARCHAR2(30)
OBJECT_ID NUMBER
DATA_OBJECT_ID NUMBER
OBJECT_TYPE VARCHAR2(19)
CREATED DATE
LAST_DDL_TIME DATE
TIMESTAMP VARCHAR2(19)
STATUS VARCHAR2(7)
TEMPORARY VARCHAR2(1)
GENERATED VARCHAR2(1)
SECONDARY VARCHAR2(1)
sys@EBANK>select count(distinct object_id) from test;
COUNT(DISTINCTOBJECT_ID)
------------------------
64000
sys@EBANK>select count(distinct object_type) from test;
COUNT(DISTINCTOBJECT_TYPE)
--------------------------
10
sys@EBANK>col column_name for a30
sys@EBANK>set lines 132
sys@EBANK>select table_name,index_name,column_name,column_position from user_ind_columns where table_name='TEST';
TABLE_NAME INDEX_NAME COLUMN_NAME COLUMN_POSITION
------------------------------ ------------------------------ ------------------------------ ---------------
TEST IDX_A OBJECT_ID 1
TEST IDX_A OBJECT_TYPE 2
TEST IDX_B OBJECT_TYPE 1
TEST IDX_B OBJECT_ID 2
sys@EBANK>set autot traceonly
sys@EBANK>select count(*) from test where object_id=1000 and object_type='VIEW';
Execution Plan
----------------------------------------------------------
Plan hash value: 1765980712
---------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 12 | 1 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 12 | | |
|* 2 | INDEX RANGE SCAN| IDX_A | 1 | 12 | 1 (0)| 00:00:01 |
---------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("OBJECT_ID"=1000 AND "OBJECT_TYPE"='VIEW')
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
2 consistent gets
0 physical reads
0 redo size
411 bytes sent via SQL*Net to client
381 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
sys@EBANK>select /*+ index(a idx_b) */ count(*) from test a where object_id=1000 and object_type='VIEW';
Execution Plan
----------------------------------------------------------
Plan hash value: 1808392406
---------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 12 | 1 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 12 | | |
|* 2 | INDEX RANGE SCAN| IDX_B | 1 | 12 | 1 (0)| 00:00:01 |
---------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("OBJECT_TYPE"='VIEW' AND "OBJECT_ID"=1000)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
2 consistent gets
0 physical reads
0 redo size
411 bytes sent via SQL*Net to client
381 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed