create table e01 as select * from emp;
insert into e01 select * from e01;
/
alter table e01 modify (empno number);
update e01 set empno=rownum
set timing on
SQL> select blocks/128 from user_segments where segment_name='E01';
BLOCKS/128
39
SQL> select * from e01 where empno=1500;
EMPNO ENAME JOB MGR HIREDATE SAL COMM
DEPTNO
1500 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
Elapsed: 00:00:00.02
set autot trace exp
SQL> set autot trace exp SQL> select * from e01 where empno=1500; Elapsed: 00:00:00.00
Execution Plan
Plan hash value: 3036185917
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 54 | 4698 | 1338 (1)| 00:00:17 | |* 1 | TABLE ACCESS FULL| E01 | 54 | 4698 | 1338 (1)| 00:00:17 |
Predicate Information (identified by operation id):
1 - filter("EMPNO"=1500)
Note
- dynamic sampling used for this statement (level=2)
SQL> select segment_name,blocks from user_segments where segment_name=upper('e01');
SEGMENT_NAME
BLOCKS
E01 4992
SQL> create index i_e01_empno on e01 (empno);
Index created.
SQL> set linesize 150 SQL> select * from e01 where empno=1500; Elapsed: 00:00:00.00
Execution Plan
Plan hash value: 2767643581
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 87 | 2 (0)| 00:00:01 | | 1 | TABLE ACCESS BY INDEX ROWID| E01 | 1 | 87 | 2 (0)| 00:00:01 | |* 2 | INDEX RANGE SCAN | I_E01_EMPNO | 1 | | 2 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("EMPNO"=1500)
Note
- dynamic sampling used for this statement (level=2)
SQL> desc index_stats Name Null? Type HEIGHT NUMBER BLOCKS NUMBER NAME VARCHAR2(30) PARTITION_NAME VARCHAR2(30) LF_ROWS NUMBER LF_BLKS NUMBER LF_ROWS_LEN NUMBER LF_BLK_LEN NUMBER BR_ROWS NUMBER BR_BLKS NUMBER BR_ROWS_LEN NUMBER BR_BLK_LEN NUMBER DEL_LF_ROWS NUMBER DEL_LF_ROWS_LEN NUMBER DISTINCT_KEYS NUMBER MOST_REPEATED_KEY NUMBER BTREE_SPACE NUMBER USED_SPACE NUMBER PCT_USED NUMBER ROWS_PER_KEY NUMBER BLKS_GETS_PER_ACCESS NUMBER PRE_ROWS NUMBER PRE_ROWS_LEN NUMBER OPT_CMPR_COUNT NUMBER OPT_CMPR_PCTSAVE NUMBER
begin dbms_stats.gather_schema_stats(ownname=>'scott', estimate_percent=>DBMS_STATS.AUTO_SAMPLE_SIZE, options=>'gather', degree=>DBMS_STATS.AUTO_DEGREE, method_opt=>'for all columns size repeat', cascade=>TRUE); END; /
SQL> select num_rows,blocks from user_tab_statistics;
NUM_ROWS BLOCKS
4 5 15 5 0 0 5 5 0 0 860160 4909
6 rows selected.
Elapsed: 00:00:00.06 SQL> select table_name,blocks from user_tables;
TABLE_NAME BLOCKS
E01 4909 T01 0 SALGRADE 5 BONUS 0 EMP 5 DEPT 5
6 rows selected.
SQL> select index_name,blevel,num_rows from user_ind_statistics;
INDEX_NAME BLEVEL NUM_ROWS
PK_DEPT 0 4 PK_EMP 0 15 I_E01_EMPNO 2 860160
select name,height,blocks,br_blks,br_rows,lf_blks,lf_rows from index_stats;
create index i_e01 on e01 (deptno); select name,height,blocks,br_blks,br_rows,lf_blks,lf_rows from index_stats; analyze index i_e01 validate structure; select name,height,blocks,br_blks,br_rows,lf_blks,lf_rows from index_stats;
NAME HEIGHT BLOCKS BR_BLKS BR_ROWS LF_BLKS LF_ROWS
I_E01 3 1664 5 1567 1568 802816
SQL> analyze index i_e01_empno validate structure;
Index analyzed.
Elapsed: 00:00:00.37 SQL> select name,height,blocks,br_blks,br_rows,lf_blks,lf_rows from index_stats;
NAME HEIGHT BLOCKS BR_BLKS BR_ROWS LF_BLKS LF_ROWS
I_E01_EMPNO 3 1920 5 1791 1792 860160
|