Skip to content

Commit 0ff7c14

Browse files
committed
fg
1 parent 6b4b1e9 commit 0ff7c14

File tree

7 files changed

+8827
-0
lines changed

7 files changed

+8827
-0
lines changed

optimizer/fine_grained/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
This directory contains examples of fine-grained cursor invalidation.
2+
3+
The test.sql is provided to give you ideas on how you can try this feature out for yourself.
4+
5+
They are in quite a raw state because I originally wrote the examples for my own benefit to explore the boundaries of this feature. In particular, there is a mixture of some DDL that *will* allow SQL statements to use rolling invalidation and some DDL will not. Some of the PROMPT comments may be incorrect now because the test was created before Oracle Database 12c R2 was released.
6+
7+
### Note
8+
9+
The example here was run on Oracle Database 12c Release 2.
10+
11+
The test case drops tables T1 and T2.
12+
13+
### DISCLAIMER
14+
15+
* These scripts are provided for educational purposes only.
16+
* They are NOT supported by Oracle World Wide Technical Support.
17+
* The scripts have been tested and they appear to work as intended.
18+
* You should always run scripts on a test instance.
19+
20+
### WARNING
21+
22+
* These scripts drop and create tables. For use on test databases

optimizer/fine_grained/plan.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
set linesize 200
2+
set tab off
3+
set pagesize 1000
4+
column plan_table_output format a180
5+
6+
SELECT *
7+
FROM table(DBMS_XPLAN.DISPLAY_CURSOR(FORMAT=>'TYPICAL'));

optimizer/fine_grained/q.sql

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
alter system flush shared_pool;
2+
3+
select /* TESTFG */ count(*) from t1 where id = 1;
4+
@plan
5+
select /* TESTFG */ count(*) from t1 where val1 = 1;
6+
@plan
7+
select /* TESTFG */ count(*) from t2 where id = 1;
8+
@plan
9+
select /* TESTFG */ count(*) from t2 where id = 1+150000;
10+
@plan
11+
select /* TESTFG */ count(*) from t2 where val1 = 1;
12+
@plan
13+
select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t;
14+
@plan
15+
select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1);
16+
@plan
17+
select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50;
18+
@plan
19+
select /* TESTFG */ count(*) from t2 partition (p2);
20+
@plan
21+
select /* TESTFG */ count(*) from t2 partition (p1);
22+
@plan
23+
update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50;
24+
update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50;
25+
update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50;
26+
update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50;
27+
commit;

optimizer/fine_grained/sql.sql

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
column EXACT_MATCHING_SIGNATURE format 99999999999999999999999999999999999
2+
set linesize 300
3+
set tab off
4+
column sql_text format a85
5+
column is_shareable format a20
6+
column IS_ROLLING_INVALID format a20
7+
column IS_ROLLING_REFRESH_INVALID format a20
8+
column DDL_NO_INVALIDATE format a20
9+
10+
select sql_id,sql_text,child_number
11+
, is_shareable, OBJECT_STATUS, INVALIDATIONS,IS_ROLLING_INVALID,IS_ROLLING_REFRESH_INVALID ,DDL_NO_INVALIDATE
12+
from v$sql
13+
where sql_text like '%TESTFG%' and sql_text not like '%v$sql%'
14+
order by 2;
15+
16+
select sql_id,is_shareable, IS_ROLLING_INVALID,IS_ROLLING_REFRESH_INVALID
17+
from v$sql
18+
where sql_text like '%TESTVG%' and sql_text not like '%v$sql%'
19+
order by 2;

optimizer/fine_grained/tab.sql

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
drop table t1;
2+
drop table t2;
3+
4+
create table t1 (id number(10) not null, val1 number(10) not null, val2 number(10) not null);
5+
6+
create table t2 (id number(10) not null, val1 number(10) not null, val2 number(10) not null)
7+
partition by range (id) (
8+
partition p1 values less than (100000)
9+
, partition p2 values less than (200000)
10+
)
11+
/
12+
13+
insert into t1 select rownum,rownum,rownum from (
14+
select 1
15+
from dual connect by rownum < 10000);
16+
17+
insert into t2 select rownum,rownum,rownum from (
18+
select 1
19+
from dual connect by rownum < 10000);
20+
21+
insert into t2 select rownum+100000,rownum,rownum from (
22+
select 1
23+
from dual connect by rownum < 10000);
24+
25+
26+
create index t1i on t1 (id);
27+
create index t2i on t2 (id) local (
28+
partition p1i,
29+
partition p2i);
30+
31+
exec dbms_stats.gather_table_stats(ownname=>user,tabname=>'t1');
32+
exec dbms_stats.gather_table_stats(ownname=>user,tabname=>'t2');

0 commit comments

Comments
 (0)