########################################################################################################### ## This file is part of http://www.gplivna.eu/papers/v$session_longops.htm ########################################################################################################### ########################################################################################################### ## Creating index organized table to simulate index ########################################################################################################### SQL> create table big1 ( 2 owner not null, 3 name not null, 4 type , 5 line , 6 text , 7 constraint big1_pk primary key (owner, name, type, line, text)) 8 organization index 9 tablespace manualtbs 10 as select owner, name, type, line, substr(text, 1, 500) from dba_source where rownum <=82150; Table created. Elapsed: 00:00:01.43 SQL> exec dbms_stats.gather_table_stats(user, 'big1'); PL/SQL procedure successfully completed. Elapsed: 00:00:01.01 ########################################################################################################### ## As we can see Oracle treats it actually as index ## We have 993 leaf blocks and unknown number of branch blocks ########################################################################################################### SQL> select blevel, leaf_blocks from user_indexes where index_name = 'BIG1_PK'; BLEVEL LEAF_BLOCKS ---------- ----------- 2 993 Elapsed: 00:00:00.01 SQL> select count(*) from v$session_longops; COUNT(*) ---------- 207 Elapsed: 00:00:00.10 SQL> select count(distinct a.line) from big1 a, big1 b 2 where a.owner = b.owner 3 and a.name = b.name 4 / COUNT(DISTINCTA.LINE) --------------------- 6440 Elapsed: 00:02:28.68 ########################################################################################################### ## Select took definitely more than 6 seconds but entries in V$session_longops ## haven't changed ########################################################################################################### SQL> select count(*) from v$session_longops; COUNT(*) ---------- 207 Elapsed: 00:00:00.00 SQL> drop table big1; Table dropped. Elapsed: 00:00:01.20 ########################################################################################################### ## Now just create the same table with a bit more rows ########################################################################################################### SQL> create table big1 ( 2 owner not null, 3 name not null, 4 type , 5 line , 6 text , 7 constraint big1_pk primary key (owner, name, type, line, text)) 8 organization index 9 tablespace manualtbs 10 as select owner, name, type, line, substr(text, 1, 500) from dba_source where rownum <=82200; Table created. Elapsed: 00:00:01.12 SQL> exec dbms_stats.gather_table_stats(user, 'big1'); PL/SQL procedure successfully completed. Elapsed: 00:00:02.11 ########################################################################################################### ## We have one more leaf block than previously ########################################################################################################### SQL> select blevel, leaf_blocks from user_indexes where index_name = 'BIG1_PK'; BLEVEL LEAF_BLOCKS ---------- ----------- 2 994 Elapsed: 00:00:00.04 SQL> select count(*) from v$session_longops; COUNT(*) ---------- 210 Elapsed: 00:00:00.03 SQL> select count(distinct a.line) from big1 a, big1 b 2 where a.owner = b.owner 3 and a.name = b.name 4 / COUNT(DISTINCTA.LINE) --------------------- 6440 Elapsed: 00:02:26.37 ########################################################################################################### ## One more entry in v$session_longops ## and it is Index Fast Full Scan ########################################################################################################### SQL> select count(*) from v$session_longops; COUNT(*) ---------- 211 Elapsed: 00:00:00.01 SQL> select * from ( 2 select opname, target, sofar, totalwork, units, elapsed_seconds, message 3 from v$session_longops order by start_time desc) 4 where rownum <=1 5 / OPNAME ---------------------------------------------------------------- TARGET SOFAR ---------------------------------------------------------------- ---------- TOTALWORK UNITS ELAPSED_SECONDS ---------- -------------------------------- --------------- MESSAGE -------------------------------------------------------------------------------- Index Fast Full Scan GINTS.BIG1 1000 1000 Blocks 147 Index Fast Full Scan: GINTS.BIG1: 1000 out of 1000 Blocks done Elapsed: 00:00:00.04