create table OLYM_MEDALS as
select * from olym.OLYM_MEDALS_VIEW
Table created.
exec dbms_stats.gather_table_stats(sys_context('userenv', 'current_user'), 'OLYM_MEDALS')
Statement processed.
create index olym_event_i on olym_medals (event)
Index created.
create index olym_medal_i on olym_medals (medal)
Index created.
create index olym_event_medal_i on olym_medals (event, medal)
Index created.
create index olym_medal_event_i on olym_medals (medal, event)
Index created.
begin
for rws in (
select /*+ gather_plan_statistics GOLD */listagg(athlete,',' on overflow truncate) within group (order by athlete)
from olym_medals
where medal = 'Gold') loop
null;
end loop;
for rws in (
select /*+ gather_plan_statistics 100M */listagg(athlete,',' on overflow truncate) within group (order by athlete)
from olym_medals
where event = '100m') loop
null;
end loop;
for rws in (
select /*+ gather_plan_statistics GO100 */listagg(athlete,',' on overflow truncate) within group (order by athlete)
from olym_medals
where medal = 'Gold' and event = '100m') loop
null;
end loop;
end;
Statement processed.
select p.*
from v$sql s, table (
dbms_xplan.display_cursor (
s.sql_id, s.child_number, 'ALLSTATS LAST'
)
) p
where s.sql_text like '%GOLD%'
and s.sql_text not like '%not this%'
and s.sql_text not like 'begin%'
PLAN_TABLE_OUTPUT | SQL_ID guzmtaapjvpa1, child number 0 | ------------------------------------- | SELECT /*+ gather_plan_statistics GOLD */LISTAGG(ATHLETE,',' ON | OVERFLOW TRUNCATE) WITHIN GROUP (ORDER BY ATHLETE) FROM OLYM_MEDALS | WHERE MEDAL = 'Gold' | Plan hash value: 1115672472 | ----------------------------------------------------------------------------------------------------------------------- | | Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem | | ----------------------------------------------------------------------------------------------------------------------- | | 0 | SELECT STATEMENT | | 1 | | 1 |00:00:00.01 | 369 | | | | | | 1 | SORT GROUP BY | | 1 | 1 | 1 |00:00:00.01 | 369 | 903K| 522K| 802K (0)| | |* 2 | TABLE ACCESS FULL| OLYM_MEDALS | 1 | 9738 | 9849 |00:00:00.02 | 369 | | | | | ----------------------------------------------------------------------------------------------------------------------- | Predicate Information (identified by operation id): | --------------------------------------------------- | 2 - filter("MEDAL"='Gold') |
---|
select p.*
from v$sql s, table (
dbms_xplan.display_cursor (
s.sql_id, s.child_number, 'ALLSTATS LAST'
)
) p
where s.sql_text like '%100M%'
and s.sql_text not like '%not this%'
and s.sql_text not like 'begin%'
PLAN_TABLE_OUTPUT | SQL_ID 3ayq17z5aswcm, child number 0 | ------------------------------------- | SELECT /*+ gather_plan_statistics 100M */LISTAGG(ATHLETE,',' ON | OVERFLOW TRUNCATE) WITHIN GROUP (ORDER BY ATHLETE) FROM OLYM_MEDALS | WHERE EVENT = '100m' | Plan hash value: 1651183729 | --------------------------------------------------------------------------------------------------------------------------------------------------- | | Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | Reads | OMem | 1Mem | Used-Mem | | --------------------------------------------------------------------------------------------------------------------------------------------------- | | 0 | SELECT STATEMENT | | 1 | | 1 |00:00:00.01 | 6 | 2 | | | | | | 1 | SORT GROUP BY | | 1 | 1 | 1 |00:00:00.01 | 6 | 2 | 13312 | 13312 |12288 (0)| | | 2 | TABLE ACCESS BY INDEX ROWID BATCHED| OLYM_MEDALS | 1 | 51 | 136 |00:00:00.01 | 6 | 2 | | | | | |* 3 | INDEX RANGE SCAN | OLYM_EVENT_I | 1 | 51 | 136 |00:00:00.01 | 3 | 2 | | | | | --------------------------------------------------------------------------------------------------------------------------------------------------- | Predicate Information (identified by operation id): | --------------------------------------------------- | 3 - access("EVENT"='100m') |
---|
select p.*
from v$sql s, table (
dbms_xplan.display_cursor (
s.sql_id, s.child_number, 'ALLSTATS LAST'
)
) p
where s.sql_text like '%GO100%'
and s.sql_text not like '%not this%'
and s.sql_text not like 'begin%'
PLAN_TABLE_OUTPUT | SQL_ID 0dnkjc7mzvd32, child number 0 | ------------------------------------- | SELECT /*+ gather_plan_statistics GO100 */LISTAGG(ATHLETE,',' ON | OVERFLOW TRUNCATE) WITHIN GROUP (ORDER BY ATHLETE) FROM OLYM_MEDALS | WHERE MEDAL = 'Gold' AND EVENT = '100m' | Plan hash value: 363132783 | ------------------------------------------------------------------------------------------------------------------------------------------------ | | Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem | | ------------------------------------------------------------------------------------------------------------------------------------------------ | | 0 | SELECT STATEMENT | | 1 | | 1 |00:00:00.01 | 5 | | | | | | 1 | SORT GROUP BY | | 1 | 1 | 1 |00:00:00.01 | 5 | 4096 | 4096 | 4096 (0)| | | 2 | TABLE ACCESS BY INDEX ROWID BATCHED| OLYM_MEDALS | 1 | 17 | 44 |00:00:00.01 | 5 | | | | | |* 3 | INDEX RANGE SCAN | OLYM_EVENT_MEDAL_I | 1 | 17 | 44 |00:00:00.01 | 2 | | | | | ------------------------------------------------------------------------------------------------------------------------------------------------ | Predicate Information (identified by operation id): | --------------------------------------------------- | 3 - access("EVENT"='100m' AND "MEDAL"='Gold') |
---|
alter index olym_event_medal_i invisible
Statement processed.
alter index olym_medal_event_i invisible
Statement processed.
begin
for rws in (
select /*+ gather_plan_statistics GO100AGAIN */listagg(athlete,',' on overflow truncate) within group (order by athlete)
from olym_medals
where medal = 'Gold' and event = '100m') loop
null;
end loop;
end;
Statement processed.
select p.*
from v$sql s, table (
dbms_xplan.display_cursor (
s.sql_id, s.child_number, 'ALLSTATS LAST'
)
) p
where s.sql_text like '%GO100AGAIN%'
and s.sql_text not like '%not this%'
and s.sql_text not like 'begin%'
PLAN_TABLE_OUTPUT | SQL_ID 5r3z4vtqd0v51, child number 0 | ------------------------------------- | SELECT /*+ gather_plan_statistics GO100AGAIN */LISTAGG(ATHLETE,',' ON | OVERFLOW TRUNCATE) WITHIN GROUP (ORDER BY ATHLETE) FROM OLYM_MEDALS | WHERE MEDAL = 'Gold' AND EVENT = '100m' | Plan hash value: 1651183729 | ------------------------------------------------------------------------------------------------------------------------------------------ | | Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem | | ------------------------------------------------------------------------------------------------------------------------------------------ | | 0 | SELECT STATEMENT | | 1 | | 1 |00:00:00.01 | 6 | | | | | | 1 | SORT GROUP BY | | 1 | 1 | 1 |00:00:00.01 | 6 | 4096 | 4096 | 4096 (0)| | |* 2 | TABLE ACCESS BY INDEX ROWID BATCHED| OLYM_MEDALS | 1 | 17 | 44 |00:00:00.01 | 6 | | | | | |* 3 | INDEX RANGE SCAN | OLYM_EVENT_I | 1 | 51 | 136 |00:00:00.01 | 3 | | | | | ------------------------------------------------------------------------------------------------------------------------------------------ | Predicate Information (identified by operation id): | --------------------------------------------------- | 2 - filter("MEDAL"='Gold') | 3 - access("EVENT"='100m') |
---|
select index_name, leaf_blocks, clustering_factor from user_indexes
INDEX_NAME | LEAF_BLOCKS | CLUSTERING_FACTOR | OLYM_EVENT_I | 111 | 916 | OLYM_EVENT_MEDAL_I | 137 | 2219 | OLYM_MEDAL_EVENT_I | 137 | 2616 | OLYM_MEDAL_I | 71 | 1059 |
---|
drop index olym_event_i
Index dropped.
drop index olym_medal_i
Index dropped.
drop index olym_event_medal_i
Index dropped.
drop index olym_medal_event_i
Index dropped.
create index olym_event_year_i on olym_medals (event, edition)
Index created.
create index olym_year_event_i on olym_medals (edition, event)
Index created.
select index_name, leaf_blocks, clustering_factor
from user_indexes
where index_name like '%EVENT%'
and index_name like '%YEAR%'
INDEX_NAME | LEAF_BLOCKS | CLUSTERING_FACTOR | OLYM_EVENT_YEAR_I | 127 | 7158 | OLYM_YEAR_EVENT_I | 127 | 7955 |
---|
alter index olym_event_year_i rebuild compress 1
Statement processed.
alter index olym_year_event_i rebuild compress 1
Statement processed.
select index_name, leaf_blocks, clustering_factor
from user_indexes
where index_name like '%EVENT%'
and index_name like '%YEAR%'
INDEX_NAME | LEAF_BLOCKS | CLUSTERING_FACTOR | OLYM_EVENT_YEAR_I | 64 | 7158 | OLYM_YEAR_EVENT_I | 111 | 7955 |
---|
alter index olym_event_year_i rebuild compress 2
Statement processed.
alter index olym_year_event_i rebuild compress 2
Statement processed.
select index_name, leaf_blocks
from user_indexes
where index_name like '%EVENT%'
and index_name like '%YEAR%'
INDEX_NAME | LEAF_BLOCKS | OLYM_EVENT_YEAR_I | 59 | OLYM_YEAR_EVENT_I | 59 |
---|
begin
for rws in (
select /*+ gather_plan_statistics EV>2000 */listagg(athlete,',' on overflow truncate) within group (order by athlete)
from olym_medals
where event = '100m' and edition > 2000) loop
null;
end loop;
end;
Statement processed.
select p.*
from v$sql s, table (
dbms_xplan.display_cursor (
s.sql_id, s.child_number, 'ALLSTATS LAST'
)
) p
where s.sql_text like '%EV>2000%'
and s.sql_text not like '%not this%'
and s.sql_text not like 'begin%'
PLAN_TABLE_OUTPUT | SQL_ID bfyjp4d5nggum, child number 0 | ------------------------------------- | SELECT /*+ gather_plan_statistics EV>2000 */LISTAGG(ATHLETE,',' ON | OVERFLOW TRUNCATE) WITHIN GROUP (ORDER BY ATHLETE) FROM OLYM_MEDALS | WHERE EVENT = '100m' AND EDITION > 2000 | Plan hash value: 97534872 | ----------------------------------------------------------------------------------------------------------------------------------------------- | | Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem | | ----------------------------------------------------------------------------------------------------------------------------------------------- | | 0 | SELECT STATEMENT | | 1 | | 1 |00:00:00.01 | 6 | | | | | | 1 | SORT GROUP BY | | 1 | 1 | 1 |00:00:00.01 | 6 | 2048 | 2048 | 2048 (0)| | | 2 | TABLE ACCESS BY INDEX ROWID BATCHED| OLYM_MEDALS | 1 | 4 | 12 |00:00:00.01 | 6 | | | | | |* 3 | INDEX RANGE SCAN | OLYM_EVENT_YEAR_I | 1 | 4 | 12 |00:00:00.01 | 2 | | | | | ----------------------------------------------------------------------------------------------------------------------------------------------- | Predicate Information (identified by operation id): | --------------------------------------------------- | 3 - access("EVENT"='100m' AND "EDITION">2000) |
---|
alter index olym_event_year_i invisible
Statement processed.
begin
for rws in (
select /*+ gather_plan_statistics EV>2000 */listagg(athlete,',' on overflow truncate) within group (order by athlete)
from olym_medals
where event = '100m' and edition > 2000) loop
null;
end loop;
end;
Statement processed.
select p.*
from v$sql s, table (
dbms_xplan.display_cursor (
s.sql_id, s.child_number, 'ALLSTATS LAST'
)
) p
where s.sql_text like '%EV>2000%'
and s.sql_text not like '%not this%'
and s.sql_text not like 'begin%'
PLAN_TABLE_OUTPUT | SQL_ID bfyjp4d5nggum, child number 1 | ------------------------------------- | SELECT /*+ gather_plan_statistics EV>2000 */LISTAGG(ATHLETE,',' ON | OVERFLOW TRUNCATE) WITHIN GROUP (ORDER BY ATHLETE) FROM OLYM_MEDALS | WHERE EVENT = '100m' AND EDITION > 2000 | Plan hash value: 2350661193 | -------------------------------------------------------------------------------------------------------------------------------------------------------- | | Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | Reads | OMem | 1Mem | Used-Mem | | -------------------------------------------------------------------------------------------------------------------------------------------------------- | | 0 | SELECT STATEMENT | | 1 | | 1 |00:00:00.01 | 8 | 3 | | | | | | 1 | SORT GROUP BY | | 1 | 1 | 1 |00:00:00.01 | 8 | 3 | 2048 | 2048 | 2048 (0)| | | 2 | TABLE ACCESS BY INDEX ROWID BATCHED| OLYM_MEDALS | 1 | 4 | 12 |00:00:00.01 | 8 | 3 | | | | | |* 3 | INDEX SKIP SCAN | OLYM_YEAR_EVENT_I | 1 | 4 | 12 |00:00:00.01 | 4 | 3 | | | | | -------------------------------------------------------------------------------------------------------------------------------------------------------- | Predicate Information (identified by operation id): | --------------------------------------------------- | 3 - access("EDITION">2000 AND "EVENT"='100m') | filter("EVENT"='100m') |
---|