Ask Tom - Using Stored Outlines PDF
Ask Tom - Using Stored Outlines PDF
Ask Tom - Using Stored Outlines PDF
Resources
Archives
Links
Popular
Hot
Files
Sreenivas -- Thanks for the question regarding "Using Stored Outlines", version 9.2.0.3
Submitted on 28-Sep-2007 23:08 Central time zone
Last updated 9-Aug-2010 14:02
You Asked
Dear Tom,
I need some help in implementing/understanding stored outlines..As per the articles provided from oracle,i understand that outlines will help in
stablizing the exectuion plan across environments(test and production).
Here are the steps that i have done and i need some clarification.Pl help me.
Here are the details of our database
Version 9.2.0.3
Optimizer mode=all_rows
select /*+ INDEX(t1 pk_tbl_data_collections)*/
t1.DATA_COLLECTION_ID,t2.object_id,t1.collection_id
from tbl_data_collections t1,tbl_object_data t2,tbl_service_data t3
where t1.DATA_COLLECTION_ID = t2.data_collection_id
and t1.OLD_COLLECTION_ID = t3.data_collection_id
and t1.collection_id = :1
and t1.active = :2
and t1.service_id = :3
for example , we have sql from the code where the binded varibales are the parameters been passed to SQL.I have observed that the cost of
explain plan for the above SQL is high and the reason is becuase of the hint applied on the query.
And the same SQL without the hint give me a much faster response time than earlier and the cost is very low.
I have the statistics upto date on the tables but the only differnece is the hint.
Now the problem is i have no control on the source code and so i thought the only way we can implement is through stored outlines.
I have followed these steps in creating the stored outlines.
alter session set create_stored_outlines=true;
create or replace outline
on
select t1.DATA_COLLECTION_ID,t2.object_id,t1.collection_id
from tbl_data_collections t1,tbl_object_data t2,tbl_service_data t3
where t1.DATA_COLLECTION_ID = t2.data_collection_id
and t1.OLD_COLLECTION_ID = t3.data_collection_id
and t1.collection_id = :1
and t1.active = :2
and t1.service_id = :3
;
alter session set use_stored_outlines=true;
When i queried view user_outlines i notice that the outline is created but not used.Why is that?
Is there any wrong in the way i was creating the outline.
I know that the SQL comming from code is not similar to the SQL that the outline is created on.Is that a problem? because i needed the query
not to use the hint.I cannot modify the source code?
Please and Please help me out Tom.
Sorry for any typos
Thanks
Sreenivas
and we said...
because the query you saved the outline for differs from the query you are actually executing.
You would need to
a) capture the query exactly as it is executed by the application, hints and all
b) get it to have the plan you want in some session by some method (eg: setting session parameters, invalidating the index referenced)
c) capturing that plan and using it.
Or, you could just rename the index, making the hint reference something that doesn't exist, so it would be ignored. Beware however that it
would be sort of "global", my experience is if the developers hinted once - they hinted a thousand times (because they didn't really understand
what they were doing...) and renaming the index would cause thousands of hints to stop being meaningful.
Reviews
Hi Tom,
I'm trying to implement outlines on a 10gR2 (10.2.0.4) on Linux, using what you provided in previous followup :
a) capture the query exactly as it is executed by the application, hints and all
b) get it to have the plan you want in some session by some method (eg: setting session parameters, invalidating the index referenced)
c) capturing that plan and using it.
This is how I do it :
create table T
(
c1 integer,
c2 integer,
c3 integer,
c4 integer,
c5 integer,
c6 integer,
c7 integer,
c8 date,
val1 varchar2(30)
);
alter table T add constraint T_pk primary key (c1, c2, c3, c4, c5, c6, c7, c8);
create index T_idx on T(c6, c7);
insert into T
select
mod(n,97),
mod(n,89),
mod(n,83),
mod(n,79),
mod(n,73),
mod(n,67),
mod(n,61),
sysdate+(n/(24*3600)),
rpad('a',30,'a'),
rpad('a',30,'a'),
rpad('a',30,'a'),
rpad('a',30,'a'),
rpad('a',30,'a'),
rpad('a',30,'a')
from (
select level n from dual connect by level <= 1000
);
begin
dbms_stats.gather_table_stats(
ownname => user,
tabname => 'T',
method_opt => 'for all columns size 1',
estimate_percent => null,
cascade => true);
end;
/
The query I want to outline is :
select
c1, c2, c3, c4, c5, c6, c7, c8
, val1
from T
where c1=19
and c2=54
and c3=28
and c4=41
and c5=16
and c6=51
and c7=18
and c8=(sysdate + 1.2345)
for update nowait;
I put it in a file called q.sql so I'm sure it's always the same (syntax wise)
I want it (for test purpose only) to range_scan T_idx instead of unique scan t_pk.
So I tried to make the index unusable before generating outline, then rebuild it and check weither outline is used or not :
SQL> alter index t_pk unusable;
Index altered.
SQL> create outline myol
2
3
4
Outline created.
SQL> alter index t_pk rebuild;
Index altered.
SQL> set autotrace traceonly explain
SQL> alter session set use_stored_outlines=myol;
Session altered.
SQL> @q
Execution Plan
---------------------------------------------------------Plan hash value: 2503694904
------------------------------------------------------------------------------------| Id | Operation
| Name | Rows | Bytes | Cost (%CPU)| Time
|
------------------------------------------------------------------------------------|
0 | SELECT STATEMENT
|
|
1 |
214 |
3
(0)| 00:00:01 |
|
1 | FOR UPDATE
|
|
|
|
|
|
|
2 |
TABLE ACCESS BY INDEX ROWID| T
|
1 |
214 |
3
(0)| 00:00:01 |
|* 3 |
INDEX UNIQUE SCAN
| T_PK |
1 |
|
2
(0)| 00:00:01 |
------------------------------------------------------------------------------------Predicate Information (identified by operation id):
--------------------------------------------------3 - access("C1"=19 AND "C2"=54 AND "C3"=28 AND "C4"=41 AND "C5"=16 AND
"C6"=51 AND "C7"=18 AND "C8"=SYSDATE@!+1.234502314814814814814814814814814814
81)
Note
----- outline "MYOL" used for this statement
I'm quite lost.... autotrace says the outline myol is used, but I see the t_pk index being used.
One of those must be lying to me, or I missed something.
Here is the content of user_outline_hints for myol outline :
SQL> select * from user_outline_hints where name='MYOL';
NAME
NODE STAGE JOIN_POS HINT
----- ----- ------ --------- ------------------------------------------------------MYOL
1
1
1 INDEX_RS_ASC(@"SEL$1" "T"@"SEL$1" ("T"."C6" "T"."C7"))
MYOL
1
1
0 OUTLINE_LEAF(@"SEL$1")
MYOL
1
1
0 ALL_ROWS
MYOL
1
1
0 OPTIMIZER_FEATURES_ENABLE('10.2.0.4')
MYOL
1
1
0 IGNORE_OPTIM_EMBEDDED_HINTS
5 rows selected.
16 rpad('a',30,'a')
17 from (
18 select level n from dual connect by level <= 1000
19 );
insert into T
*
ERROR at line 1:
ORA-00913: too many values
please run things like I do and provide SQLPlus CUT AND PASTE so we know what you actually run - not what you might have intended
to run...
I feel stupid... April 15, 2010 - 4am Central time zone
Reviewer: Nicosa from Paris, France
Sorry Tom,
Trying to make it easier to read, I removed what I thought would be extra-columns... This was stupid.
All my apologizes.
I use 3 files for my example :
-> createTable.sql :
create table T
(
c1 integer,
c2 integer,
c3 integer,
c4 integer,
c5 integer,
c6 integer,
c7 integer,
c8 date,
val1 varchar2(30),
val2 varchar2(30),
val3 varchar2(30),
val4 varchar2(30),
val5 varchar2(30),
val6 varchar2(30)
);
alter table T add constraint T_pk primary key (c1, c2, c3, c4, c5, c6, c7, c8);
create index T_idx on T(c6, c7);
insert into T
select
mod(n,97),
mod(n,89),
mod(n,83),
mod(n,79),
mod(n,73),
mod(n,67),
mod(n,61),
sysdate+(n/(24*3600)),
rpad('a',30,'a'),
rpad('a',30,'a'),
rpad('a',30,'a'),
rpad('a',30,'a'),
rpad('a',30,'a'),
rpad('a',30,'a')
from (
select level n from dual connect by level <= 1000
);
commit;
begin
dbms_stats.gather_table_stats(
ownname => user,
tabname => 'T',
method_opt => 'for all columns size 1',
estimate_percent => null,
cascade => true);
end;
/
-> q.sql (the query) :
select
c1, c2, c3, c4, c5, c6, c7, c8
, val1, val2, val3, val4, val5, val6
from T
where c1=19
and c2=54
and c3=28
and
and
and
and
and
for
c4=41
c5=16
c6=51
c7=18
c8=(sysdate + 1.2345)
update nowait;
lines 100
tab off
echo on
feed on
long 30000
@createTable.sql
alter index t_pk unusable;
create outline myol for category myol on
@q.sql
alter index t_pk rebuild;
alter session set use_stored_outlines=myol;
set autotrace traceonly explain
@q.sql
set autotrace off
col name for A4
col hint for A55
col node for 99999
col stage for 99999
select * from user_outline_hints where name='MYOL';
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Session altered.
SQL>
SQL>
SQL>
SQL>
SQL>
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
set feed on
set long 30000
@createTable.sql
create table T
(
c1 integer,
c2 integer,
c3 integer,
c4 integer,
c5 integer,
c6 integer,
c7 integer,
c8 date,
val1 varchar2(30),
val2 varchar2(30),
val3 varchar2(30),
val4 varchar2(30),
val5 varchar2(30),
val6 varchar2(30)
);
Table created.
SQL>
SQL> alter table T add constraint T_pk primary key (c1, c2, c3, c4, c5, c6, c7, c8);
Table altered.
SQL>
SQL> create index T_idx on T(c6, c7);
Index created.
SQL>
SQL>
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
insert into T
select
mod(n,97),
mod(n,89),
mod(n,83),
mod(n,79),
mod(n,73),
mod(n,67),
mod(n,61),
sysdate+(n/(24*3600)),
rpad('a',30,'a'),
rpad('a',30,'a'),
rpad('a',30,'a'),
rpad('a',30,'a'),
rpad('a',30,'a'),
rpad('a',30,'a')
from (
select level n from dual connect by level <= 1000
);
begin
dbms_stats.gather_table_stats(
ownname => user,
tabname => 'T',
method_opt => 'for all columns size 1',
estimate_percent => null,
cascade => true);
end;
/
Outline created.
SQL>
SQL> alter index t_pk rebuild;
Index altered.
SQL>
SQL> alter session set use_stored_outlines=myol;
Session altered.
SQL>
SQL>
SQL>
SQL>
SQL>
2
3
4
5
6
7
8
9
10
11
12
13
and
and
and
and
for
c5=16
c6=51
c7=18
c8=(sysdate + 1.2345)
update nowait;
Execution Plan
---------------------------------------------------------Plan hash value: 2503694904
------------------------------------------------------------------------------------| Id | Operation
| Name | Rows | Bytes | Cost (%CPU)| Time
|
------------------------------------------------------------------------------------|
0 | SELECT STATEMENT
|
|
1 |
214 |
2
(0)| 00:00:01 |
|
1 | FOR UPDATE
|
|
|
|
|
|
|
2 |
TABLE ACCESS BY INDEX ROWID| T
|
1 |
214 |
2
(0)| 00:00:01 |
|* 3 |
INDEX UNIQUE SCAN
| T_PK |
1 |
|
1
(0)| 00:00:01 |
------------------------------------------------------------------------------------Predicate Information (identified by operation id):
--------------------------------------------------3 - access("C1"=19 AND "C2"=54 AND "C3"=28 AND "C4"=41 AND "C5"=16 AND
"C6"=51 AND "C7"=18 AND "C8"=SYSDATE@!+1.234502314814814814814814814814814814
81)
Note
----- outline "MYOL" used for this statement
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
NAME
NODE STAGE
JOIN_POS HINT
---- ------ ------ ---------- ------------------------------------------------------MYOL
1
1
1 INDEX_RS_ASC(@"SEL$1" "T"@"SEL$1" ("T"."C6" "T"."C7"))
MYOL
1
1
0 OUTLINE_LEAF(@"SEL$1")
MYOL
1
1
0 ALL_ROWS
MYOL
1
1
0 OPTIMIZER_FEATURES_ENABLE('10.2.0.4')
MYOL
1
1
0 IGNORE_OPTIM_EMBEDDED_HINTS
5 rows selected.
9
10
11
12
13
14
15
16
17
c7 integer,
c8 date,
val1 varchar2(30),
val2 varchar2(30),
val3 varchar2(30),
val4 varchar2(30),
val5 varchar2(30),
val6 varchar2(30)
);
Table created.
ops$tkyte%ORA10GR2>
ops$tkyte%ORA10GR2> alter table T add constraint T_pk primary key (c1, c2, c3, c4, c5, c6, c7, c8);
Table altered.
ops$tkyte%ORA10GR2>
ops$tkyte%ORA10GR2> create index T_idx on T(c6, c7);
Index created.
ops$tkyte%ORA10GR2>
ops$tkyte%ORA10GR2> insert into T
2 select
3 mod(n,97),
4 mod(n,89),
5 mod(n,83),
6 mod(n,79),
7 mod(n,73),
8 mod(n,67),
9 mod(n,61),
10 sysdate+(n/(24*3600)),
11 rpad('a',30,'a'),
12 rpad('a',30,'a'),
13 rpad('a',30,'a'),
14 rpad('a',30,'a'),
15 rpad('a',30,'a'),
16 rpad('a',30,'a')
17 from (
18 select level n from dual connect by level <= 1000
19 );
1000 rows created.
ops$tkyte%ORA10GR2> commit;
Commit complete.
ops$tkyte%ORA10GR2>
ops$tkyte%ORA10GR2> begin
2 dbms_stats.gather_table_stats(
3 ownname => user,
4 tabname => 'T',
5 method_opt => 'for all columns size 1',
6 estimate_percent => null,
7 cascade => true);
8 end;
9 /
PL/SQL procedure successfully completed.
ops$tkyte%ORA10GR2>
ops$tkyte%ORA10GR2> @q.sql
ops$tkyte%ORA10GR2> select
2 c1, c2, c3, c4, c5, c6, c7, c8
3 , val1, val2, val3, val4, val5, val6
4 from T
5 where c1=19
6 and c2=54
7 and c3=28
8 and c4=41
9 and c5=16
10 and c6=51
11 and c7=18
12 and c8=(sysdate + 1.2345)
13 for update nowait;
no rows selected
ops$tkyte%ORA10GR2> select * from table(dbms_xplan.display_cursor);
PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------SQL_ID 0hp10pkdk56ky, child number 0
------------------------------------select c1, c2, c3, c4, c5, c6, c7, c8 , val1, val2, val3, val4, val5, val6
from T where c1=19 and c2=54 and c3=28 and c4=41 and c5=16 and c6=51 and
12
13
14
and c7=18
and c8=(sysdate + 1.2345)
for update nowait;
Outline created.
ops$tkyte%ORA10GR2>
ops$tkyte%ORA10GR2> alter index t_pk rebuild;
Index altered.
ops$tkyte%ORA10GR2>
ops$tkyte%ORA10GR2> alter session set use_stored_outlines=myol;
Session altered.
ops$tkyte%ORA10GR2> set serveroutput off
ops$tkyte%ORA10GR2> @q.sql
ops$tkyte%ORA10GR2> select
2 c1, c2, c3, c4, c5, c6, c7, c8
3 , val1, val2, val3, val4, val5, val6
4 from T
5 where c1=19
6 and c2=54
7 and c3=28
8 and c4=41
9 and c5=16
10 and c6=51
11 and c7=18
12 and c8=(sysdate + 1.2345)
13 for update nowait;
no rows selected
ops$tkyte%ORA10GR2> select * from table(dbms_xplan.display_cursor);
PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------SQL_ID 0hp10pkdk56ky, child number 0
------------------------------------select c1, c2, c3, c4, c5, c6, c7, c8 , val1, val2, val3, val4, val5, val6
from T where c1=19 and c2=54 and c3=28 and c4=41 and c5=16 and c6=51 and
c7=18 and c8=(sysdate + 1.2345) for update nowait
Plan hash value: 882521605
-------------------------------------------------------------------------------| Id | Operation
| Name | Rows | Bytes | Cost (%CPU)| Time
-------------------------------------------------------------------------------|
0 | SELECT STATEMENT
|
|
|
|
2 (100)|
|
1 | FOR UPDATE
|
|
|
|
|
|* 2 |
TABLE ACCESS BY INDEX ROWID| T
|
1 |
214 |
2
(0)| 00:0
|* 3 |
INDEX RANGE SCAN
| T_IDX |
1 |
|
1
(0)| 00:0
-------------------------------------------------------------------------------Predicate Information (identified by operation id):
--------------------------------------------------2 - filter(("C1"=19 AND "C2"=54 AND "C3"=28 AND "C4"=41 AND "C5"=16 AND
"C8"=SYSDATE@!+1.23450231481481481481481481481481481481))
3 - access("C6"=51 AND "C7"=18)
Note
----- outline "MYOL" used for this statement
28 rows selected.
ops$tkyte%ORA10GR2> set autotrace traceonly explain
ops$tkyte%ORA10GR2> @q.sql
ops$tkyte%ORA10GR2> select
2 c1, c2, c3, c4, c5, c6, c7, c8
3 , val1, val2, val3, val4, val5, val6
4 from T
5 where c1=19
6 and c2=54
7 and c3=28
8 and c4=41
9 and c5=16
10 and c6=51
11 and c7=18
12 and c8=(sysdate + 1.2345)
13 for update nowait;
Execution Plan
---------------------------------------------------------Plan hash value: 882521605
-------------------------------------------------------------------------------| Id | Operation
| Name | Rows | Bytes | Cost (%CPU)| Time
-------------------------------------------------------------------------------|
0 | SELECT STATEMENT
|
|
1 |
214 |
2
(0)| 00:0
|
1 | FOR UPDATE
|
|
|
|
|
|* 2 |
TABLE ACCESS BY INDEX ROWID| T
|
1 |
214 |
2
(0)| 00:0
|* 3 |
INDEX RANGE SCAN
| T_IDX |
1 |
|
1
(0)| 00:0
-------------------------------------------------------------------------------Predicate Information (identified by operation id):
--------------------------------------------------2 - filter("C1"=19 AND "C2"=54 AND "C3"=28 AND "C4"=41 AND "C5"=16 AND
"C8"=SYSDATE@!+1.23450231481481481481481481481481481481)
3 - access("C6"=51 AND "C7"=18)
Note
----- outline "MYOL" used for this statement
ops$tkyte%ORA10GR2> set autotrace off
ops$tkyte%ORA10GR2> select * from v$version;
BANNER
---------------------------------------------------------------Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
PL/SQL Release 10.2.0.4.0 - Production
CORE
10.2.0.4.0
Production
TNS for Linux: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
This my sandbox db... April 15, 2010 - 9am Central time zone
Reviewer: Nicosa from Paris, France
Tom,
the test is done on my "sandbox" db (I use to test lots of things on it, so init parameters might be anything... but I don't remember doing
something spcially strange).
Would the following query show it ?
SQL> select name, value from v$parameter where isdefault!='TRUE';
NAME
-----------------------------processes
sessions
nls_language
nls_territory
nls_date_format
sga_target
control_files
VALUE
-----------------------------------------------------------50
60
FRENCH
FRANCE
yyyy/mm/dd hh24:mi:ss
209715200
/oracleDatas/MY10G/controlfile/o1_mf_58tpcw32_.ctl, /oracleD
atas/MY10G/controlfile/o1_mf_58tpcwc5_.ctl
db_block_size
compatible
log_archive_dest
db_file_multiblock_read_count
db_create_file_dest
db_recovery_file_dest_size
undo_management
undo_tablespace
remote_login_passwordfile
db_domain
dispatchers
job_queue_processes
background_dump_dest
user_dump_dest
max_dump_file_size
core_dump_dest
audit_file_dest
db_name
open_cursors
pga_aggregate_target
8192
10.2.0.3.0
/oracleDatas/MY10G/archivelog/
16
/oracleDatas
1073741824
AUTO
UNDOTBS1
EXCLUSIVE
(PROTOCOL=TCP) (SERVICE=my10gXDB)
10
/oracleSofts/product/10g/admin/my10g/bdump
/oracleSofts/product/10g/admin/my10g/udump
1024000
/oracleSofts/product/10g/admin/my10g/cdump
/oracleSofts/product/10g/admin/my10g/adump
my10g
300
52428800
27 rows selected.
I also tried to change star_transformation_enabled to true (but didn't bounce the DB since as it is supposed to be
sys_modifiable=immediate) but with no effect.
connect /
alter system flush shared_pool;
Doesn't compute... (^_^) April 15, 2010 - 12pm Central time zone
Reviewer: Nicosa from Paris, France
Tom,
Thanks for your time !
This part doesn't compute on my machine :
SQL> connect /
ERROR:
ORA-01017: invalid username/password; logon denied
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> set linesize 10000
SQL> drop table t purge;
drop table t purge
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> drop outline myol;
drop outline myol
*
ERROR at line 1:
ORA-18002: the specified outline does not exist
SQL>
SQL>
SQL>
SQL>
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
c5 integer,
c6 integer,
c7 integer,
c8 date,
val1 varchar2(30),
val2 varchar2(30),
val3 varchar2(30),
val4 varchar2(30),
val5 varchar2(30),
val6 varchar2(30)
);
Table created.
SQL>
SQL> alter table T add constraint T_pk primary key (c1, c2, c3, c4, c5, c6, c7, c8);
Table altered.
SQL>
SQL> create index T_idx on T(c6, c7);
Index created.
SQL>
SQL>
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
insert into T
select
mod(n,97),
mod(n,89),
mod(n,83),
mod(n,79),
mod(n,73),
mod(n,67),
mod(n,61),
sysdate+(n/(24*3600)),
rpad('a',30,'a'),
rpad('a',30,'a'),
rpad('a',30,'a'),
rpad('a',30,'a'),
rpad('a',30,'a'),
rpad('a',30,'a')
from (
select level n from dual connect by level <= 1000
);
begin
dbms_stats.gather_table_stats(
ownname => user,
tabname => 'T',
method_opt => 'for all columns size 1',
estimate_percent => null,
cascade => true);
end;
/
@q.sql
select
c1, c2, c3, c4, c5, c6, c7, c8
, val1, val2, val3, val4, val5, val6
from T
where c1=19
and c2=54
and c3=28
and c4=41
and c5=16
and c6=51
and c7=18
and c8=(sysdate + 1.2345)
for update nowait;
no rows selected
SQL> select * from table(dbms_xplan.display_cursor);
PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------SQL_ID 0hp10pkdk56ky, child number 0
-------------------------------------
select c1, c2, c3, c4, c5, c6, c7, c8 , val1, val2, val3, val4, val5, val6
from T where c1=19 and c2=54 and c3=28 and c4=41 and c5=16 and c6=51 and
c7=18 and c8=(sysdate + 1.2345) for update nowait
Plan hash value: 2503694904
-------------------------------------------------------------------------------| Id | Operation
| Name | Rows | Bytes | Cost (%CPU)| Time
-------------------------------------------------------------------------------PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------|
0 | SELECT STATEMENT
|
|
|
|
2 (100)|
|
1 | FOR UPDATE
|
|
|
|
|
|
2 |
TABLE ACCESS BY INDEX ROWID| T
|
1 |
214 |
2
(0)| 00:00
|* 3 |
INDEX UNIQUE SCAN
| T_PK |
1 |
|
1
(0)| 00:00
-------------------------------------------------------------------------------Predicate Information (identified by operation id):
--------------------------------------------------3 - access("C1"=19 AND "C2"=54 AND "C3"=28 AND "C4"=41 AND "C5"=16 AND
"C6"=51 AND "C7"=18 AND "C8"=SYSDATE@!+1.2345023148148148148148148
PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------81)
24 rows selected.
SQL> alter index t_pk unusable;
Index altered.
SQL>
SQL>
2
3
4
5
6
7
8
9
10
11
12
13
@q.sql
select
c1, c2, c3, c4, c5, c6, c7, c8
, val1, val2, val3, val4, val5, val6
from T
where c1=19
and c2=54
and c3=28
and c4=41
and c5=16
and c6=51
and c7=18
and c8=(sysdate + 1.2345)
for update nowait;
no rows selected
SQL> select * from table(dbms_xplan.display_cursor);
PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------SQL_ID 0hp10pkdk56ky, child number 0
------------------------------------select c1, c2, c3, c4, c5, c6, c7, c8 , val1, val2, val3, val4, val5, val6
from T where c1=19 and c2=54 and c3=28 and c4=41 and c5=16 and c6=51 and
c7=18 and c8=(sysdate + 1.2345) for update nowait
Plan hash value: 882521605
-------------------------------------------------------------------------------| Id | Operation
| Name | Rows | Bytes | Cost (%CPU)| Time
-------------------------------------------------------------------------------PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------|
0 | SELECT STATEMENT
|
|
|
|
2 (100)|
|
1 | FOR UPDATE
|
|
|
|
|
|* 2 |
TABLE ACCESS BY INDEX ROWID| T
|
1 |
214 |
2
(0)| 00:0
|* 3 |
INDEX RANGE SCAN
| T_IDX |
1 |
|
1
(0)| 00:0
-------------------------------------------------------------------------------Predicate Information (identified by operation id):
--------------------------------------------------2 - filter(("C1"=19 AND "C2"=54 AND "C3"=28 AND "C4"=41 AND "C5"=16 AND
"C8"=SYSDATE@!+1.23450231481481481481481481481481481481))
PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------3 - access("C6"=51 AND "C7"=18)
24 rows selected.
SQL>
SQL>
2
2
3
4
5
6
7
8
9
10
11
12
13
14
Outline created.
SQL>
SQL> alter index t_pk rebuild;
Index altered.
SQL>
SQL>
SQL>
SQL>
SQL> connect /as sysdba
Connected.
SQL> alter system flush shared_pool;
System altered.
SQL>
SQL> conn scott/tiger
Connected.
SQL>
SQL>
SQL> alter session set use_stored_outlines=myol;
Session altered.
SQL>
SQL>
SQL>
2
3
4
5
6
7
8
9
10
11
12
13
no rows selected
SQL> select * from table(dbms_xplan.display_cursor);
PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------SQL_ID 0hp10pkdk56ky, child number 0
------------------------------------select c1, c2, c3, c4, c5, c6, c7, c8 , val1, val2, val3, val4, val5, val6
from T where c1=19 and c2=54 and c3=28 and c4=41 and c5=16 and c6=51 and
c7=18 and c8=(sysdate + 1.2345) for update nowait
Plan hash value: 2503694904
-------------------------------------------------------------------------------| Id | Operation
| Name | Rows | Bytes | Cost (%CPU)| Time
-------------------------------------------------------------------------------PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------|
0 | SELECT STATEMENT
|
|
|
|
2 (100)|
|
1 | FOR UPDATE
|
|
|
|
|
|
2 |
TABLE ACCESS BY INDEX ROWID| T
|
1 |
214 |
2
(0)| 00:00
|* 3 |
INDEX UNIQUE SCAN
| T_PK |
1 |
|
1
(0)| 00:00
-------------------------------------------------------------------------------Predicate Information (identified by operation id):
---------------------------------------------------
3 - access("C1"=19 AND "C2"=54 AND "C3"=28 AND "C4"=41 AND "C5"=16 AND
"C6"=51 AND "C7"=18 AND "C8"=SYSDATE@!+1.2345023148148148148148148
PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------81)
Note
----- outline "MYOL" used for this statement
28 rows selected.
SQL>
SQL>
SQL>
2
3
4
5
6
7
8
9
10
11
12
13
Execution Plan
---------------------------------------------------------Plan hash value: 2503694904
-------------------------------------------------------------------------------| Id | Operation
| Name | Rows | Bytes | Cost (%CPU)| Time
-------------------------------------------------------------------------------|
0 | SELECT STATEMENT
|
|
1 |
214 |
2
(0)| 00:00
|
1 | FOR UPDATE
|
|
|
|
|
|
2 |
TABLE ACCESS BY INDEX ROWID| T
|
1 |
214 |
2
(0)| 00:00
|* 3 |
INDEX UNIQUE SCAN
| T_PK |
1 |
|
1
(0)| 00:00
-------------------------------------------------------------------------------Predicate Information (identified by operation id):
--------------------------------------------------3 - access("C1"=19 AND "C2"=54 AND "C3"=28 AND "C4"=41 AND "C5"=16 AND
"C6"=51 AND "C7"=18 AND "C8"=SYSDATE@!+1.2345023148148148148148148
81)
Note
----- outline "MYOL" used for this statement
SQL> set autotrace off
SQL>
Still the strange behavior...
By the way, i had the opportunity to test it on another database (Linux OS too, same DB version) and it worked...
(of course, the test is not exactly the same as it is a true table with true data, and the query was using bind variables)
That would make me think the problem is with my "sandbox" db... I must have done something strange to it.
If I have time tomorrow, I'll create a brand new DB on the same system to see if this reproduces.
you wouldn't have my user/password - and actually mine is just blank and blank.
How does OUTLINE work for same query with different HASH_VALUE June 15, 2010 - 2am Central time zone
Bookmark | Bottom | Top
Reviewer: Sanju
Oracle Version: 9.2.0.8
Hi Tom,
My application is executing a query which is of HASH_VALUE=568965. I take this query and run the same from SQLPLUS. The
HASH_VALUE changes to 687956. I can understand why this happens.
Now when I create the Stored Outline, it says the HASH_VALUE is 687956(The one I executed from SQLPLUS). If I set the system to use
the STORED_OUTLINE and execute the query from the application, I can see that the executed query is of HASH_VALUE 568965(since
executed from application) but the stored outline is still used. How is this possible? As HASH_VALUE from OUTLN.OL$ says that it is on
687956. So should not it be executing only when HASH_VALUE is 687956(sqlplus) and not 568965(application).
Please can you explain this??
Thank You,
Sanju
Please can you explain?
Hi,
We are upgrading from 9.2 to 11.1 and find that due to having several GROUP BY queries without
ORDER BY (even though we need them to be ordered), will of course not be ordered in our 'new' db
due to the introduction of HASH GROUP BY algorithm.
There are lots of code changes to be made (approx 200 objects) and the testing of course. We will
not meet our deadline.
The options are to use the hidden parameter _gby_hash_aggregation_enabled, or get all the stored
outlines from the 9i database, test each one to ensure that they are being used as we expect them
to, or change all the code and miss the deadline. Is there any other way, and if not what would you
recommend please?
... There are lots of code changes to be made (approx 200 objects) and the testing
of course. We will not meet our deadline.
...
I would explain to management that the developed code has a serious bug that must be fixed.
That is what I would recommend. Anything else will not actually get the problem fixed - ever.
CREATE_STORED_OUTLINES - Missing in 9iR2. August 9, 2010 - 12pm Central time zone
Bookmark | Bottom | Top
Reviewer: Rajeshwaran Jeyabal
test@9iR2> select * from v$version;
BANNER
-----------------------------------------------------------Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
PL/SQL Release 9.2.0.8.0 - Production
CORE
9.2.0.8.0
Production
TNS for 32-bit Windows: Version 9.2.0.8.0 - Production
NLSRTL Version 9.2.0.8.0 - Production
test@9iR2> show parameter create_stored;
test@9iR2>
test@9iR2>
test@9iR2> show parameter create;
NAME
TYPE
VALUE
------------------------------------ ----------- -----------------------------create_bitmap_area_size
integer
8388608
db_create_file_dest
string
db_create_online_log_dest_1
string
db_create_online_log_dest_2
string
db_create_online_log_dest_3
string
db_create_online_log_dest_4
string
db_create_online_log_dest_5
string
test@9iR2>
test@9iR2>
test@9iR2>
test@9iR2>
test@9iR2> show parameter CREATE_STORED_OUTLINES;
test@9iR2>
test@9iR2>
test@9iR2>
test@9iR2>
test@9iR2> SELECT *
2 FROM V$PARAMETER
3 WHERE upper(NAME) LIKE '%CREATE_STORED_OUTLINES%'
4 /
no rows selected
Elapsed: 00:00:00.00
test@9iR2>
VALUE
------------------------------------
Elapsed: 00:00:00.03
Tom:
Referring from Oracle product documentation, I could not find create_stored_outlines in 9iR2, Is that missing in 9.2.0.8 patch sets?
http://download.oracle.com/docs/cd/B10501_01/server.920/a96533/outlines.htm#26854
http://download.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_23a.htm#2071573
... The CREATE_STORED_OUTLINES parameter determines whether Oracle should automatically create and store an outline for each
query submitted on the system. CREATE_STORED_OUTLINES is not an initialization parameter. ...
Write a Review
All information and materials provided here are provided "as-is"; Oracle disclaims all express and implied warranties, including, the implied warranties of merchantability or fitness
for a particular use. Oracle shall not be liable for any damages, including, direct, indirect, incidental, special or consequential damages for loss of profits, revenue, data or data
use, incurred by you or any third party in connection with the use of this information or these materials.