SlideShare a Scribd company logo
28/11/15 Mohamed Houri www.hourim.wordpress.com
1
Adaptive Cursor Sharing
Short answer to sharing cursors and optimizing SQL
Mohamed Houri
www.hourim.wordpress.com
Mohamed Houri
www.hourim.wordpress.com
28/11/15 Mohamed Houri www.hourim.wordpress.com
2
Agenda
Set the scene
Expose the performance problem caused by sharing cursors
Literal, bind variable, bind variable peeking and hard parsing
Introduce Adaptive Cursor Sharing feature
Adaptive Cursor Sharing
Explain the cursor bind sensitive property
Explain the cursor bind aware property
Show a simple practical ACS example
Explain the ACS monitoring v$sql views
Uncover the bind aware secret sauce
Show how ACS can introduce a serious perfomance issue
Conclusion
28/11/15 Mohamed Houri www.hourim.wordpress.com
3
WHAT IS THE PROBLEM?
PART 0
Set the scene
28/11/15 Mohamed Houri www.hourim.wordpress.com
4
Syntactic check
Syntax, keywords
Semantic check
Access, right, exist Store parent cursor in
v$sql(SGA)
Logical Optimization
Physical Optimization
Store child cursor in
v$sql(SGA)
Parent
cursor?
Child
cursor?
Execute SQL
No
No
Yes
Yes
Set the scene
Hardparse
Softparse
28/11/15 Mohamed Houri www.hourim.wordpress.com
5
Using Literal variable
➔
hard parsing for each execution
➔
traumatizes the SGA
➔
burns a lot CPU
Set the scene
Using bind variables
➔
avoids hard parsing
➔
makes the SGA attractive
➔
uses less resource - CPU
generates “always“ an optimal plan
sharing plan is not always optimal
28/11/15 Mohamed Houri www.hourim.wordpress.com
6
How to have best-of-both-world?
Set the scene
➔ Attractive SGA + less CPU consumption
➔ Optimal execution plan for each execution
Adaptive Cursor Sharing-ACS
28/11/15 Mohamed Houri www.hourim.wordpress.com
7
ACS - triggering diagram
Invesigate this property
28/11/15 Mohamed Houri www.hourim.wordpress.com
8
WHEN A CURSOR IS BIND SENSITIVE?
PART I
ACS
28/11/15 Mohamed Houri www.hourim.wordpress.com
9
SQL> desc V$SQL
Name Null? Type
------------------------------- -------- -------------
1 SQL_TEXT VARCHAR2(1000)
2 SQL_FULLTEXT CLOB
3 SQL_ID VARCHAR2(13)
45 CHILD_NUMBER NUMBER
63 IS_OBSOLETE VARCHAR2(1)
64 IS_BIND_SENSITIVE VARCHAR2(1)
65 IS_BIND_AWARE VARCHAR2(1)
66 IS_SHAREABLE VARCHAR2(1)
ACS - v$sql
28/11/15 Mohamed Houri www.hourim.wordpress.com
10
ACS – model
SQL> create table t_acs(n1 number, n2 number);
SQL> BEGIN
for j in 1..1200150 loop
if j = 1 then
insert into t_acs values (j, 1);
elsif j>1 and j<=101 then
insert into t_acs values(j, 100);
elsif j>101 and j<=1101 then
insert into t_acs values (j, 1000);
elsif j>10001 and j<= 110001 then
insert into t_acs values(j,10000);
else
insert into t_acs values(j, 1000000);
end if;
end loop;
commit;
END;
Inflexion point
Inflexion point
28/11/15 Mohamed Houri www.hourim.wordpress.com
11
ACS – model
SQL> create index t_acs_i1 on t_acs(n2);
SQL> BEGIN
dbms_stats.gather_table_stats
(user
,'t_acs'
,method_opt => 'for all columns size 1'
,cascade => true
,estimate_percent => dbms_stats.auto_sample_size
);
END;
/
–- declare and affect a value to a bind variable
–- and run a query with range predicate
SQL> var ln2 number;
SQL> exec :ln2 := 100;
Without histogram
28/11/15 Mohamed Houri www.hourim.wordpress.com
12
ACS – bind sensitive : range predicate
SQL> select count(1) from t_acs where n2 <= :ln2;
SQL> select
sql_id
,child_number
,is_bind_sensitive
from
v$sql
where
sql_id = 'ct0yv82p15jdw';
SQL_ID CHILD_NUMBER IS_BIND_SENSITIVE
------------- ------------ -----------------
ct0yv82p15jdw 0 Y
range predicate
cursor is bind sensitive
28/11/15 Mohamed Houri www.hourim.wordpress.com
13
ACS – bind sensitive : equality predicate with histogram
SQL> BEGIN
dbms_stats.gather_table_stats
(user,'t_acs'
,method_opt => 'for all columns size auto'
,cascade => true
,estimate_percent => dbms_stats.auto_sample_size);
END;/
SQL> SELECT
column_name,
histogram
FROM user_tab_col_statistics
WHERE table_name = 'T_ACS'
AND column_name = 'N2';
COLUMN_NAME HISTOGRAM
----------------- -----------
N2 FREQUENCY
with histogram
with histogram
28/11/15 Mohamed Houri www.hourim.wordpress.com
14
ACS – bind sensitive : equality predicate with histogram
SQL> select count(1) from t_acs where n2 = :ln2;
SQL> select
sql_id
,child_number
,is_bind_sensitive
from
v$sql
where
sql_id = 'f2pmwazy1rnfd';
SQL_ID CHILD_NUMBER IS_BIND_SENSITIVE
------------- ------------ –-----------------
f2pmwazy1rnfd 0 Y
equality predicate
with histogram
cursor is bind sensitive
28/11/15 Mohamed Houri www.hourim.wordpress.com
15
ACS – bind sensitive : partition key
SQL> create table t_acs_part(n1 number, n2 number)
partition by range (n2)
( partition p1 values less than (100)
,partition p2 values less than (1000)
,partition p3 values less than (10000)
,partition p4 values less than (100000)
,partition p5 values less than (1000000)
,partition p6 values less than (10000000));
SQL> –- insert data and gather stats without histogram
SQL> select column_name, histogram
FROM user_tab_col_statistics
where table_name = 'T_ACS_PART' AND column_name = 'N2';
COLUMN_NAM HISTOGRAM
---------- ---------
N2 NONE
28/11/15 Mohamed Houri www.hourim.wordpress.com
16
ACS – bind sensitive : partition key
SQL> select count(1) from t_acs where n2 = :ln2;
SQL> select
sql_id
,child_number
,is_bind_sensitive
from
v$sql
where
sql_id = 'byztzuffb65n9';
SQL_ID CHILD_NUMBER IS_BIND_SENSITIVE
------------- ------------ –----------------
byztzuffb65n9 0 Y
partition key
cursor is bind sensitive
28/11/15 Mohamed Houri www.hourim.wordpress.com
17
ACS – bind sensitive : summary
range predicate (with simple statistics)
SQL> select count(1) from t_acs where n2 <= :ln2;
equality predicate (with histogram)
SQL> select count(1) from t_acs where n2 = :ln2;
predicate with partition key (simple stats)
SQL> select count(1) from t_acs where n2 = :ln2;
28/11/15 Mohamed Houri www.hourim.wordpress.com
18
18
PART II
ACS-simple example
A SIMPLE ACS EXAMPLE
28/11/15 Mohamed Houri www.hourim.wordpress.com
19
ACS-simple example
SQL> exec :ln2 := 100
SQL> select count(1) from t_acs where n2 = :ln2;
SQL> select n2,count(1) from t_acs group by n2 order by 2;
N2 COUNT(1)
---------- ----------
1 1
100 100
1000 1000
10000 100000
1000000 1099049
index range scan
full table scan
28/11/15 Mohamed Houri www.hourim.wordpress.com
20
ACS-simple example
SQL_ID f2pmwazy1rnfd, child number 0
-----------------------------------------------------
| Id | Operation | Name | Rows | Bytes |
-----------------------------------------------------
| 0 | SELECT STATEMENT | | | |
| 1 | SORT AGGREGATE | | 1 | 3 |
|* 2 | INDEX RANGE SCAN| T_ACS_I1 | 856 | 2568 |
-----------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("N2"=:LN2)
optimal plan for the first execution.
Plan has been hard parsed
28/11/15 Mohamed Houri www.hourim.wordpress.com
21
ACS-simple example
SQL> exec :ln2 := 1000000
–- 1st
execution with bind variable value = 1000000
SQL> select count(1) from t_acs where n2 = :ln2;
SQL_ID f2pmwazy1rnfd, child number 0
-----------------------------------------------------
| Id | Operation | Name | Rows | Bytes |
-----------------------------------------------------
| 0 | SELECT STATEMENT | | | |
| 1 | SORT AGGREGATE | | 1 | 3 |
|* 2 | INDEX RANGE SCAN| T_ACS_I1 | 856 | 2568 |
-----------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("N2"=:LN2)
sharing plan is bad here
28/11/15 Mohamed Houri www.hourim.wordpress.com
22
ACS-simple example
SQL> exec :ln2 := 1000000
–- 2nd
execution with bind variable value = 1000000
SQL> select count(1) from t_acs where n2 = :ln2;
SQL_ID f2pmwazy1rnfd, child number 1
-----------------------------------------------------
| Id | Operation | Name | Rows | Bytes |
-----------------------------------------------------
| 0 | SELECT STATEMENT | | | |
| 1 | SORT AGGREGATE | | 1 | 3 |
|* 2 | TABLE ACCESS FULL| T_ACS | 1104K| 3235K|
-----------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 – filter("N2"=:LN2) optimal plan at the second
execution
28/11/15 Mohamed Houri www.hourim.wordpress.com
23
ACS-simple example
–- back to the first bind variable value 100
SQL> exec :ln2 := 100
SQL> select count(1) from t_acs where n2 = :ln2;
SQL_ID f2pmwazy1rnfd, child number 2
------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |
------------------------------------------------------
| 0 | SELECT STATEMENT | | | |
| 1 | SORT AGGREGATE | | 1 | 3 |
|* 2 | INDEX RANGE SCAN| T_ACS_I1 | 1713 | 5139 |
------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 – access("N2"=:LN2) execution plan is now immediately
optimal
28/11/15 Mohamed Houri www.hourim.wordpress.com
24
SQL> select
sql_id
,child_number
,is_bind_sensitive
,is_bind_aware
from
v$sql
where
sql_id = 'f2pmwazy1rnfd';
SQL_ID CHILD_NUMBER IS_BIND_SENS IS_BIND_AWARE
------------- ------------ –----------- –-------------
f2pmwazy1rnfd 0 Y N → index-RS
f2pmwazy1rnfd 1 Y Y → table-FS
f2pmwazy1rnfd 2 Y Y → index-RS
is that cursor is now bind aware
what happens?
ACS-simple example
28/11/15 Mohamed Houri www.hourim.wordpress.com
25
ACS-simple example
We have gone wrong(index range scan plan shared) during the
first execution with :ln2 := 1000000
It is until the second execution with :ln2 := 1000000 that Oracle has
compiled a new optimal plan (full table scan)
We have to share the “wrong” plan during a certain number of
executions
This “certain number” of executions is strongly related to the number
of executions done at the initial bind variable value :ln2 := 100
This execution-count relationship will be explained later
(BUCKET_ID, COUNT)
28/11/15 Mohamed Houri www.hourim.wordpress.com
26
26
PART III
ACS-bind aware secret sauce
When Oracle decides that it is time to compile
a new execution plan?
28/11/15 Mohamed Houri www.hourim.wordpress.com
27
27
SQL> desc V$SQL_CS_STATISTICS
Name Null? Type
------------------------------- -------- --------------
1 ADDRESS RAW(8)
2 HASH_VALUE NUMBER
3 SQL_ID VARCHAR2(13)
4 CHILD_NUMBER NUMBER
5 BIND_SET_HASH_VALUE NUMBER
6 PEEKED VARCHAR2(1)
7 EXECUTIONS NUMBER
8 ROWS_PROCESSED NUMBER
9 BUFFER_GETS NUMBER
10 CPU_TIME NUMBER
11 CON_ID NUMBER
ACS-bind aware secret sauce
Starting from 12c this
view is obsolete
28/11/15 Mohamed Houri www.hourim.wordpress.com
28
28
SQL> desc V$SQL_CS_HISTOGRAM
Name Null? Type
------------------------------- -------- -------------
1 ADDRESS RAW(8)
2 HASH_VALUE NUMBER
3 SQL_ID VARCHAR2(13)
4 CHILD_NUMBER NUMBER
5 BUCKET_ID NUMBER
6 COUNT NUMBER
7 CON_ID NUMBER
ACS-bind aware secret sauce
number of executions
done at this child_number
linked to the number of
rows processed by
this child_number
28/11/15 Mohamed Houri www.hourim.wordpress.com
29
29
SQL> desc V$SQL_CS_SELECTIVITY
Name Null? Type
----------------------- -------- --------------
1 ADDRESS RAW(8)
2 HASH_VALUE NUMBER
3 SQL_ID VARCHAR2(13)
4 CHILD_NUMBER NUMBER
5 PREDICATE VARCHAR2(40)
6 RANGE_ID NUMBER
7 LOW VARCHAR2(10)
8 HIGH VARCHAR2(10)
9 CON_ID NUMBER
ACS-bind aware secret sauce
This view becomes useful
only when cursor is
bind aware
28/11/15 Mohamed Houri www.hourim.wordpress.com
30
30
ACS-bind aware secret sauce
0 <= ROWS_PROCESSED< 1,000
increments COUNT
of BUCKET_ID n° 0
1,000 <= ROWS_PROCESSED<= 1,000,000
increments COUNT
of BUCKET_ID n° 1
ROWS_PROCESSED> 1,000,000
increments COUNT
of BUCKET_ID n° 2
Inflexion point
Inflexion point
28/11/15 Mohamed Houri www.hourim.wordpress.com
31
SQL> exec :ln2 := 100 –- 1st
execution with this value
SQL> select count(1) from t_acs where n2 = :ln2;
COUNT(1)
----------
100
ACS-bind aware secret sauce
Nbr of rows processed <1000
SQL> select
child_number,bucket_id,count
from
v$sql_cs_histogram
where sql_id = 'f2pmwazy1rnfd' ;
CHILD_NUMBER BUCKET_ID COUNT
------------ ---------- ----------
0 0 1
0 1 0
0 2 0
count(bucket_id n°0)
incremented
28/11/15 Mohamed Houri www.hourim.wordpress.com
32
SQL> exec :ln2 := 100 –- 2nd
execution with this value
SQL> select count(1) from t_acs where n2 = :ln2;
COUNT(1)
----------
100
ACS-bind aware secret sauce
SQL> select
child_number,bucket_id,count
from
v$sql_cs_histogram
where sql_id = 'f2pmwazy1rnfd' ;
CHILD_NUMBER BUCKET_ID COUNT
------------ ---------- ----------
0 0 2
0 1 0
0 2 0
count(bucket_id n°0)
incremented
Nbr of rows processed <1000
28/11/15 Mohamed Houri www.hourim.wordpress.com
33
SQL> exec :ln2 := 100 –- 3rd
execution with this value
SQL> select count(1) from t_acs where n2 = :ln2;
COUNT(1)
----------
100
ACS-bind aware secret sauce
SQL> select
child_number,bucket_id,count
from
v$sql_cs_histogram
where sql_id = 'f2pmwazy1rnfd' ;
CHILD_NUMBER BUCKET_ID COUNT
------------ ---------- ----------
0 0 3
0 1 0
0 2 0
count(bucket_id n°0)
incremented
Nbr of rows processed <1000
28/11/15 Mohamed Houri www.hourim.wordpress.com
34
SQL> exec :ln2 := 1000 –- 1st
execution with this value
SQL> select count(1) from t_acs where n2 = :ln2;
COUNT(1)
-------
1000
ACS-bind aware secret sauce
SQL> select
child_number,bucket_id,count
from
v$sql_cs_histogram
where sql_id = 'f2pmwazy1rnfd' ;
CHILD_NUMBER BUCKET_ID COUNT
------------ ---------- ----------
0 0 3
0 1 1
0 2 0
count(bucket_id n°1)
incremented
1000<= Nbr of rows processed <= 1e6
still sharing same plan
28/11/15 Mohamed Houri www.hourim.wordpress.com
35
SQL> exec :ln2 := 1000 –-2nd
execution with this value
SQL> select count(1) from t_acs where n2 = :ln2;
COUNT(1)
-------
1000
ACS-bind aware secret sauce
SQL> select
child_number,bucket_id,count
from
v$sql_cs_histogram
where sql_id = 'f2pmwazy1rnfd' ;
CHILD_NUMBER BUCKET_ID COUNT
------------ ---------- ----------
0 0 3
0 1 2
0 2 0
count(bucket_id n°1)
incremented
1000<= Nbr of rows processed <= 1e6
still sharing same plan
28/11/15 Mohamed Houri www.hourim.wordpress.com
36
SQL> exec :ln2 := 1000 –-3rd
execution with this value
SQL> select count(1) from t_acs where n2 = :ln2;
COUNT(1)
-------
1000
ACS-bind aware secret sauce
SQL> select
child_number,bucket_id,count
from
v$sql_cs_histogram
where sql_id = 'f2pmwazy1rnfd' ;
CHILD_NUMBER BUCKET_ID COUNT
------------ ---------- ----------
0 0 3
0 1 3
0 2 0
count(bucket_id n°1)
incremented
1000<= Nbr of rows processed <= 1e6
still sharing same plan
28/11/15 Mohamed Houri www.hourim.wordpress.com
37
SQL> exec :ln2 := 1000 –-4th
execution with this value
SQL> select count(1) from t_acs where n2 = :ln2;
ACS-bind aware secret sauce
SQL> select
child_number,bucket_id,count
from
v$sql_cs_histogram
where sql_id = 'f2pmwazy1rnfd' ;
CHILD_NUMBER BUCKET_ID COUNT
------------ ---------- ----------
1 0 0
1 1 1
1 2 0
0 0 3
0 1 3
0 2 0
count(bucket_id n°1)
incremented
new compiled plan
28/11/15 Mohamed Houri www.hourim.wordpress.com
38
SQL> select
sql_id
,child_number
,is_bind_sensitive
,is_bind_aware
from
v$sql
where
sql_id = 'f2pmwazy1rnfd';
SQL_ID CHILD_NUMBER IS_BIND_SENS IS_BIND_AWARE
------------- ------------ –----------- –-------------
f2pmwazy1rnfd 0 Y N
f2pmwazy1rnfd 1 Y Y
cursor n° 1 is now bind aware
ACS-bind aware secret sauce
28/11/15 Mohamed Houri www.hourim.wordpress.com
39
39
ACS-bind aware secret sauce – rule n° 1 : adjacent buckets
COUNT(BUCKET_ID n° 1) = COUNT(BUCKET_ID n° 0)
OR
COUNT(BUCKET_ID n° 2) = COUNT(BUCKET_ID n° 1)
The next execution at BUCKET_ID n°1 (or n°2) will
 mark the cursor bind aware
 and a new execution plan will be compiled
28/11/15 Mohamed Houri www.hourim.wordpress.com
40
SQL> exec :ln2 := 100 –- bucket_id n° 0
SQL> select count(1) from t_acs where n2 = :ln2;
SQL> ../.. 10 executions
ACS-bind aware secret sauce : distant bucket_id
SQL> select
child_number,bucket_id,count
from
v$sql_cs_histogram
where sql_id = 'f2pmwazy1rnfd' ;
CHILD_NUMBER BUCKET_ID COUNT
------------ ---------- ----------
0 0 10
0 1 0
0 2 0
count(bucket_id n°0)
Incremented 10 times
28/11/15 Mohamed Houri www.hourim.wordpress.com
41
SQL> exec :ln2 := 1000000 –- bucket_id n°2
SQL> select count(1) from t_acs where n2 = :ln2;
COUNT(1)
----------
1099049
ACS-bind aware secret sauce : distant bucket_id
SQL> select
child_number,bucket_id,count
from
v$sql_cs_histogram
where sql_id = 'f2pmwazy1rnfd' ;
CHILD_NUMBER BUCKET_ID COUNT
------------ ---------- ----------
0 0 10
0 1 0
0 2 1
count(bucket_id n°2)
Incremented 1 time
still sharing same plan
Nbr of rows > 1e6
28/11/15 Mohamed Houri www.hourim.wordpress.com
42
Question : How many executions at bucket_id n°2 we need to have
before Oracle compile a new optimal plan?
ACS-bind aware secret sauce : distant bucket_id
–- run this 3 times
SQL> select count(1) from t_acs where n2 = :ln2;
SQL> select
child_number,bucket_id,count
from
v$sql_cs_histogram
where sql_id = 'f2pmwazy1rnfd' ;
CHILD_NUMBER BUCKET_ID COUNT
------------ ---------- ----------
0 0 10
0 1 0
0 2 4
count(bucket_id n°2)
incremented 3 times
Answer : 4 executions
still sharing the
same plan
28/11/15 Mohamed Houri www.hourim.wordpress.com
43
SQL> exec :ln2 := 1000000 –-5th
execution at this value
SQL> select count(1) from t_acs where n2 = :ln2;
SQL> select
child_number,bucket_id,count
from
v$sql_cs_histogram
where sql_id = 'f2pmwazy1rnfd' ;
CHILD_NUMBER BUCKET_ID COUNT
------------ ---------- ----------
1 0 0
1 1 0
1 2 1
0 0 10
0 1 0
0 2 4
10 exec at bucket_id n°0
new compiled plan
ACS-bind aware secret sauce : distant bucket_id
4 exec at bucket_id n°2
28/11/15 Mohamed Houri www.hourim.wordpress.com
44
44
4 = ceil (10/3)
The next execution at BUCKET_ID n°2 will
 mark the cursor bind aware
 and a new execution plan will be compiled
ACS-bind aware secret sauce : distant bucket_id
Applies only with distant bucket_id (0 and 2)
COUNT(BUCKET_ID n° 2) = ceil (COUNT(BUCKET_ID n° 0)/3)
28/11/15 Mohamed Houri www.hourim.wordpress.com
45
ACS-bind aware secret sauce : all buckets involved
SQL> select
child_number,bucket_id,count
from
v$sql_cs_histogram
where sql_id = 'f2pmwazy1rnfd' ;
CHILD_NUMBER BUCKET_ID COUNT
------------ ---------- ----------
0 0 10
0 1 3
0 2 1
Question : How many executions at bucket_id n°2 we need to have
before Oracle compiles a new optimal plan?
10 exec at bucket_id n°0
3 exec at bucket_id n°1
1 exec at bucket_id n°2
28/11/15 Mohamed Houri www.hourim.wordpress.com
46
ACS-bind aware secret sauce : all buckets involved
------------------------------------------------------------------------------
-- File name: fv_will_cs_be_bind_aware
-- Author : Mohamed Houri (Mohamed.Houri@gmail.com)
-- Date : 29/08/2015
-- Purpose : When supplied with 3 parameters
-- pin_cnt_bucket_0 : count of bucket_id n°0
-- pin_cnt_bucket_1 : count of bucket_id n°1
-- pin_cnt_bucket_2 : count of bucket_id n°2
-- this function will return a status:
-- 'Y' if the next execution at any bucket_id will mark the cursor bind aware
-- 'N' if the next execution any bucket_id will NOT mark the cursor bind aware
--------------------------------------------------------------------------------
create or replace function fv_will_cs_be_bind_aware
(pin_cnt_bucket_0 in number,pin_cnt_bucket_1 in number,pin_cnt_bucket_2 in number)
return varchar2 is
lv_will_be_bind_aware varchar2(1) := 'N';
ln_least_0_2 number := least(pin_cnt_bucket_0,pin_cnt_bucket_2);
ln_great_0_2 number := greatest(pin_cnt_bucket_0,pin_cnt_bucket_2);
begin
if pin_cnt_bucket_0 + pin_cnt_bucket_2 > = pin_cnt_bucket_1
and ln_least_0_2 >= ceil ((ln_great_0_2-pin_cnt_bucket_1)/3)then
return 'Y';
else
return 'N';
end if;
end fv_will_cs_be_bind_aware;
28/11/15 Mohamed Houri www.hourim.wordpress.com
47
ACS-bind aware secret sauce : all buckets involved
SQL> select
child_number,bucket_id,count
from
v$sql_cs_histogram
where sql_id = 'f2pmwazy1rnfd' ;
CHILD_NUMBER BUCKET_ID COUNT
------------ ---------- ----------
0 0 10
0 1 3
0 2 1
SQL> select fv_will_cs_be_bind_aware(10,3,1) acs from dual;
ACS
----
N
next execution will share the same plan
28/11/15 Mohamed Houri www.hourim.wordpress.com
48
SQL> exec :ln2 := 1000000 –- 2nd
execution at this value
SQL> select count(1) from t_acs where n2 = :ln2;
SQL> select
child_number,bucket_id,count
from
v$sql_cs_histogram
where sql_id = 'f2pmwazy1rnfd' ;
CHILD_NUMBER BUCKET_ID COUNT
------------ ---------- ----------
0 0 10
0 1 3
0 2 2
SQL> select fv_will_cs_be_bind_aware(10,3,2) acs from dual;
ACS
----
N next execution will share the same plan
ACS-bind aware secret sauce : all buckets involved
28/11/15 Mohamed Houri www.hourim.wordpress.com
49
SQL> exec :ln2 := 1000000 –- 3rd
execution at this value
SQL> select count(1) from t_acs where n2 = :ln2;
SQL> select
child_number,bucket_id,count
from
v$sql_cs_histogram
where sql_id = 'f2pmwazy1rnfd' ;
CHILD_NUMBER BUCKET_ID COUNT
------------ ---------- ----------
0 0 10
0 1 3
0 2 3
SQL> select fv_will_cs_be_bind_aware(10,3,3) acs from dual;
ACS
----
Y next execution will compile a new plan
ACS-bind aware secret sauce : all buckets involved
28/11/15 Mohamed Houri www.hourim.wordpress.com
50
SQL> exec :ln2 := 1000000 –- 4th
execution at this value
SQL> select count(1) from t_acs where n2 = :ln2;
SQL> select
child_number,bucket_id,count
from
v$sql_cs_histogram
where sql_id = 'f2pmwazy1rnfd' ;
CHILD_NUMBER BUCKET_ID COUNT
------------ ---------- ----------
1 0 0
1 1 0
1 2 1
0 0 10
0 1 3
0 2 3
new execution plan compiled
ACS-bind aware secret sauce : all buckets involved
28/11/15 Mohamed Houri www.hourim.wordpress.com
51
51
The next exection at any BUCKET will
 mark the cursor bind aware
 and a new execution plan will be
compiled
SQL> select
fv_will_cs_be_bind_aware
(pin_cnt_bucket_0
,pin_cnt_bucket_1
,pin_cnt_bucket_2 )
from dual;
Existing plan will be
shared
N Y
Not extensively tested!!!
ACS-bind aware secret sauce : all buckets involved
28/11/15 Mohamed Houri www.hourim.wordpress.com
52
52
ACS-bind aware secret sauce : summary
COUNT(BUCKET_ID 1) =
COUNT(BUCKET_ID 0)
ADJACENT BUCKET_ID
(0-1 or 1-2)
next execution will compile
a new execution plan
COUNT(BUCKET_ID 2) =
CEIL(COUNT(BUCKET_ID 0)
/3)
next execution will compile
a new execution plan
DISTANT BUCKET_ID
(0-2)
select
fv_will_cs_be_bind_aware
(0,1,2) from dual; → Y
next execution will compile
a new execution plan
ALL BUCKET_ID
involved
28/11/15 Mohamed Houri www.hourim.wordpress.com
53
53
PART IV
Extended Cursor Sharing
Extended Cursor Sharing- ECS
28/11/15 Mohamed Houri www.hourim.wordpress.com
54
54
Extended Cursor Sharing
Adaptive Cursor Sharing
Extended Cursor Sharing
is responsible for marking bind aware
a bind sensitive cursor provided one of
the 3 rules is satisfied
is responsible for checking if an execution
plan of a bind aware cursor has to be
shared or a new plan has to be compiled
according to the bind variable selectivity
it peeks at each execution
28/11/15 Mohamed Houri www.hourim.wordpress.com
55
SQL> select
sql_id
,child_number
,is_bind_sensitive
,is_bind_aware
from
v$sql
where
sql_id = 'f2pmwazy1rnfd';
SQL_ID CHILD_NUMBER IS_BIND_SENS IS_BIND_AWARE
------------- ------------ –----------- –-------------
f2pmwazy1rnfd 0 Y N
f2pmwazy1rnfd 1 Y Y
once a cursor is bind aware a row exists in v$sql_cs_selectivity
Extended Cursor Sharing
28/11/15 Mohamed Houri www.hourim.wordpress.com
56
SQL> select
child_number
,predicate
,low
,high
From v$sql_cs_selectivity
where sql_id = 'f2pmwazy1rnfd';
CHILD_NUMBER PREDICATE LOW HIGH
------------ ------------- ---------- ----------
2 =LN2 0.827448 1.011325
1 =LN2 0.000807 0.000986
Extended Cursor Sharing
for each execution bind variable selectivity is
checked: if it exists in one of the LOW-HIGH
ranges then share plan. If not then compile a new
plan and insert/update a new LOW-HIGH range
this is ECS
28/11/15 Mohamed Houri www.hourim.wordpress.com
57
57
PART V
Extended Cursor Sharing causing a performance issue
When ACS (in fact ECS) becomes a serious
performance threat
28/11/15 Mohamed Houri www.hourim.wordpress.com
58
SQL> select
sql_id
,count(1)
from
v$sql
where executions < 2
group by sql_id
having count(1) > 10
order by 2 desc;
SQL_ID COUNT(1)
------------- ----------
7zwq7z1nj7vga 44217
Extended Cursor Sharing causing a performance issue
Why this high nbr
of versions?
28/11/15 Mohamed Houri www.hourim.wordpress.com
59
SQL> @nonshared 7zwq7z1nj7vga
Show why existing SQL child cursors were not reused(V$SQL_SHARED_CURSOR)
-----------------
SQL_ID : 7zwq7z1nj7vga
ADDRESS : 000000406DBB30F8
CHILD_ADDRESS : 00000042CE36F7E8
CHILD_NUMBER : 99
BIND_EQUIV_FAILURE : Y
REASON :<ChildNode><ChildNumber>0</ChildNumber><ID>40</ID>
<reason>Bindmismatch(33)</reason><size>2x4</size>
<init_ranges_in_first_pass>0</init_ranges_in_first_pass>
<selectivity>1097868685</selectivity>
</ChildNode>
Extended Cursor Sharing causing a performance issue
100 exec plans (0-99)
due to bind_equivalent_failure
28/11/15 Mohamed Houri www.hourim.wordpress.com
60
SQL> select count(1)
from v$sql_shared_cursor
Where sql_id = '7zwq7z1nj7vga';
COUNT(1)
----------
45125
SQL> select count(1)
from v$sql_shared_cursor
Where sql_id = '7zwq7z1nj7vga'
and BIND_EQUIV_FAILURE = 'Y';
COUNT(1)
----------
45121
99% of non shared cursors are due to
BIND_EQUIV_FAILURE
Extended Cursor Sharing causing a performance issue
28/11/15 Mohamed Houri www.hourim.wordpress.com
61
BIND_EQUIV_FAILURE : bind value's selectivity does
not match that used to optimize the existing child
cursor
SQL> select
count(1)
from
v$sql_cs_selectivity
where
sql_id = '7zwq7z1nj7vga';
COUNT(1)
----------
16,847,320 !!!
for each execution ECS
will check this view!!!
Extended Cursor Sharing causing a performance issue
CHILD_NUMBER PREDICATE LOW HIGH
------------ ------------- ---------- ----------
2 =LN2 0.827448 1.011325
28/11/15 Mohamed Houri www.hourim.wordpress.com
62
Extended Cursor Sharing causing a performance issue
Run a query using a bind aware cursor
Oracle (ECS layer code) will do behind the scene:
1. peeks at the bind variable value
2. runs a query against v$sql_cs_selectivity(16M of rows)
3. if low < selectivity < high then share existing plan
4. if selectity not found in low-high range then hard parse a new plan
If another user executes the same query:
1. Oracle will try to do the above 1-4 steps
2. if Oracle is still busy with above 1-4 steps then we start experiencing:
a) cursor: pin S wait on X
b) library cache lock
28/11/15 Mohamed Houri www.hourim.wordpress.com
63
63
PART V
Adaptive-Extended Cursor Sharing
FINAL ACS-ECS DIAGRAM
https://hourim.wordpress.com/2015/08/12/adaptive-cursor-sharing-triggering-mechanism/
28/11/15 Mohamed Houri www.hourim.wordpress.com
64
64
Adaptive Cursor Sharing
•Conclusion
• Literal variables are good for query performance
• very bad for resource and memory
• and they produce a non scalable application
• Bind variables are not always good for query performance
• very good for resource and memory
• and they produce a scalable application
• Adaptive cursor sharing allows query good performance
• even when using bind variable
• but be aware of the extra parsing work it might introduce
Ad

More Related Content

What's hot (20)

Mark Farnam : Minimizing the Concurrency Footprint of Transactions
Mark Farnam  : Minimizing the Concurrency Footprint of TransactionsMark Farnam  : Minimizing the Concurrency Footprint of Transactions
Mark Farnam : Minimizing the Concurrency Footprint of Transactions
Kyle Hailey
 
DBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should KnowDBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should Know
Alex Zaballa
 
Flex Cluster e Flex ASM - GUOB Tech Day - OTN TOUR LA Brazil 2014
Flex Cluster e Flex ASM - GUOB Tech Day - OTN TOUR LA Brazil 2014Flex Cluster e Flex ASM - GUOB Tech Day - OTN TOUR LA Brazil 2014
Flex Cluster e Flex ASM - GUOB Tech Day - OTN TOUR LA Brazil 2014
Alex Zaballa
 
UKOUG, Oracle Transaction Locks
UKOUG, Oracle Transaction LocksUKOUG, Oracle Transaction Locks
UKOUG, Oracle Transaction Locks
Kyle Hailey
 
Indexing in Exadata
Indexing in ExadataIndexing in Exadata
Indexing in Exadata
Enkitec
 
Profiling the logwriter and database writer
Profiling the logwriter and database writerProfiling the logwriter and database writer
Profiling the logwriter and database writer
Kyle Hailey
 
Troubleshooting Complex Oracle Performance Problems with Tanel Poder
Troubleshooting Complex Oracle Performance Problems with Tanel PoderTroubleshooting Complex Oracle Performance Problems with Tanel Poder
Troubleshooting Complex Oracle Performance Problems with Tanel Poder
Tanel Poder
 
Wait Events 10g
Wait Events 10gWait Events 10g
Wait Events 10g
sagai
 
Mini Session - Using GDB for Profiling
Mini Session - Using GDB for ProfilingMini Session - Using GDB for Profiling
Mini Session - Using GDB for Profiling
Enkitec
 
Tuning SQL for Oracle Exadata: The Good, The Bad, and The Ugly Tuning SQL fo...
 Tuning SQL for Oracle Exadata: The Good, The Bad, and The Ugly Tuning SQL fo... Tuning SQL for Oracle Exadata: The Good, The Bad, and The Ugly Tuning SQL fo...
Tuning SQL for Oracle Exadata: The Good, The Bad, and The Ugly Tuning SQL fo...
Enkitec
 
In Memory Database In Action by Tanel Poder and Kerry Osborne
In Memory Database In Action by Tanel Poder and Kerry OsborneIn Memory Database In Action by Tanel Poder and Kerry Osborne
In Memory Database In Action by Tanel Poder and Kerry Osborne
Enkitec
 
In Search of Plan Stability - Part 1
In Search of Plan Stability - Part 1In Search of Plan Stability - Part 1
In Search of Plan Stability - Part 1
Enkitec
 
11 Things About11g
11 Things About11g11 Things About11g
11 Things About11g
fcamachob
 
Create your oracle_apps_r12_lab_with_less_than_us1000
Create your oracle_apps_r12_lab_with_less_than_us1000Create your oracle_apps_r12_lab_with_less_than_us1000
Create your oracle_apps_r12_lab_with_less_than_us1000
Ajith Narayanan
 
How oracle 12c flexes its muscles against oracle 11g r2 final
How oracle 12c flexes its muscles against oracle 11g r2 finalHow oracle 12c flexes its muscles against oracle 11g r2 final
How oracle 12c flexes its muscles against oracle 11g r2 final
Ajith Narayanan
 
Christo kutrovsky oracle, memory & linux
Christo kutrovsky   oracle, memory & linuxChristo kutrovsky   oracle, memory & linux
Christo kutrovsky oracle, memory & linux
Kyle Hailey
 
Drilling Deep Into Exadata Performance
Drilling Deep Into Exadata PerformanceDrilling Deep Into Exadata Performance
Drilling Deep Into Exadata Performance
Enkitec
 
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 2
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 2Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 2
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 2
Tanel Poder
 
Indexes From the Concept to Internals
Indexes From the Concept to InternalsIndexes From the Concept to Internals
Indexes From the Concept to Internals
Deiby Gómez
 
Oracle Exadata 1Z0-485 Certification
Oracle Exadata 1Z0-485 CertificationOracle Exadata 1Z0-485 Certification
Oracle Exadata 1Z0-485 Certification
Exadatadba
 
Mark Farnam : Minimizing the Concurrency Footprint of Transactions
Mark Farnam  : Minimizing the Concurrency Footprint of TransactionsMark Farnam  : Minimizing the Concurrency Footprint of Transactions
Mark Farnam : Minimizing the Concurrency Footprint of Transactions
Kyle Hailey
 
DBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should KnowDBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should Know
Alex Zaballa
 
Flex Cluster e Flex ASM - GUOB Tech Day - OTN TOUR LA Brazil 2014
Flex Cluster e Flex ASM - GUOB Tech Day - OTN TOUR LA Brazil 2014Flex Cluster e Flex ASM - GUOB Tech Day - OTN TOUR LA Brazil 2014
Flex Cluster e Flex ASM - GUOB Tech Day - OTN TOUR LA Brazil 2014
Alex Zaballa
 
UKOUG, Oracle Transaction Locks
UKOUG, Oracle Transaction LocksUKOUG, Oracle Transaction Locks
UKOUG, Oracle Transaction Locks
Kyle Hailey
 
Indexing in Exadata
Indexing in ExadataIndexing in Exadata
Indexing in Exadata
Enkitec
 
Profiling the logwriter and database writer
Profiling the logwriter and database writerProfiling the logwriter and database writer
Profiling the logwriter and database writer
Kyle Hailey
 
Troubleshooting Complex Oracle Performance Problems with Tanel Poder
Troubleshooting Complex Oracle Performance Problems with Tanel PoderTroubleshooting Complex Oracle Performance Problems with Tanel Poder
Troubleshooting Complex Oracle Performance Problems with Tanel Poder
Tanel Poder
 
Wait Events 10g
Wait Events 10gWait Events 10g
Wait Events 10g
sagai
 
Mini Session - Using GDB for Profiling
Mini Session - Using GDB for ProfilingMini Session - Using GDB for Profiling
Mini Session - Using GDB for Profiling
Enkitec
 
Tuning SQL for Oracle Exadata: The Good, The Bad, and The Ugly Tuning SQL fo...
 Tuning SQL for Oracle Exadata: The Good, The Bad, and The Ugly Tuning SQL fo... Tuning SQL for Oracle Exadata: The Good, The Bad, and The Ugly Tuning SQL fo...
Tuning SQL for Oracle Exadata: The Good, The Bad, and The Ugly Tuning SQL fo...
Enkitec
 
In Memory Database In Action by Tanel Poder and Kerry Osborne
In Memory Database In Action by Tanel Poder and Kerry OsborneIn Memory Database In Action by Tanel Poder and Kerry Osborne
In Memory Database In Action by Tanel Poder and Kerry Osborne
Enkitec
 
In Search of Plan Stability - Part 1
In Search of Plan Stability - Part 1In Search of Plan Stability - Part 1
In Search of Plan Stability - Part 1
Enkitec
 
11 Things About11g
11 Things About11g11 Things About11g
11 Things About11g
fcamachob
 
Create your oracle_apps_r12_lab_with_less_than_us1000
Create your oracle_apps_r12_lab_with_less_than_us1000Create your oracle_apps_r12_lab_with_less_than_us1000
Create your oracle_apps_r12_lab_with_less_than_us1000
Ajith Narayanan
 
How oracle 12c flexes its muscles against oracle 11g r2 final
How oracle 12c flexes its muscles against oracle 11g r2 finalHow oracle 12c flexes its muscles against oracle 11g r2 final
How oracle 12c flexes its muscles against oracle 11g r2 final
Ajith Narayanan
 
Christo kutrovsky oracle, memory & linux
Christo kutrovsky   oracle, memory & linuxChristo kutrovsky   oracle, memory & linux
Christo kutrovsky oracle, memory & linux
Kyle Hailey
 
Drilling Deep Into Exadata Performance
Drilling Deep Into Exadata PerformanceDrilling Deep Into Exadata Performance
Drilling Deep Into Exadata Performance
Enkitec
 
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 2
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 2Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 2
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 2
Tanel Poder
 
Indexes From the Concept to Internals
Indexes From the Concept to InternalsIndexes From the Concept to Internals
Indexes From the Concept to Internals
Deiby Gómez
 
Oracle Exadata 1Z0-485 Certification
Oracle Exadata 1Z0-485 CertificationOracle Exadata 1Z0-485 Certification
Oracle Exadata 1Z0-485 Certification
Exadatadba
 

Viewers also liked (15)

Webinar Uniworld e Qualitours 2016
Webinar Uniworld e Qualitours 2016Webinar Uniworld e Qualitours 2016
Webinar Uniworld e Qualitours 2016
Qualitours
 
Virtual City Company Profile 26 July VC Highlights
Virtual City Company Profile 26 July VC HighlightsVirtual City Company Profile 26 July VC Highlights
Virtual City Company Profile 26 July VC Highlights
VirtualCityKe
 
MyCruise Qualitours - O site que você já conhece, agora pode ser SEU
MyCruise Qualitours - O site que você já conhece, agora pode ser SEUMyCruise Qualitours - O site que você já conhece, agora pode ser SEU
MyCruise Qualitours - O site que você já conhece, agora pode ser SEU
Qualitours
 
Web 2.0
Web 2.0Web 2.0
Web 2.0
Karen_lmolina
 
cv with portfolio set
cv with portfolio setcv with portfolio set
cv with portfolio set
Haseeb Ahmad
 
ใบงานที่ 10
ใบงานที่ 10ใบงานที่ 10
ใบงานที่ 10
Aungkana Na Na
 
Av01 gomezperla
Av01 gomezperlaAv01 gomezperla
Av01 gomezperla
perlart
 
New Farm Africa project to help boost grain trade across East Africa
New Farm Africa project to help boost grain trade across East AfricaNew Farm Africa project to help boost grain trade across East Africa
New Farm Africa project to help boost grain trade across East Africa
Milling and Grain magazine
 
Music genre
Music genreMusic genre
Music genre
TBaeM
 
Resume- Du Yaqiong
Resume- Du YaqiongResume- Du Yaqiong
Resume- Du Yaqiong
du yaqiong
 
Leidy
LeidyLeidy
Leidy
chaconlidy
 
ContinuousImprovement-certificate
ContinuousImprovement-certificateContinuousImprovement-certificate
ContinuousImprovement-certificate
Monique Bourgeois
 
GEODI : a Practical Information Management Solution For Construction Sector
GEODI : a Practical Information Management Solution For Construction SectorGEODI : a Practical Information Management Solution For Construction Sector
GEODI : a Practical Information Management Solution For Construction Sector
serdarak2
 
Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...
Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...
Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...
Carlos Sierra
 
Teorias del comercio internacional
Teorias del comercio internacionalTeorias del comercio internacional
Teorias del comercio internacional
Bernardo Zavahra
 
Webinar Uniworld e Qualitours 2016
Webinar Uniworld e Qualitours 2016Webinar Uniworld e Qualitours 2016
Webinar Uniworld e Qualitours 2016
Qualitours
 
Virtual City Company Profile 26 July VC Highlights
Virtual City Company Profile 26 July VC HighlightsVirtual City Company Profile 26 July VC Highlights
Virtual City Company Profile 26 July VC Highlights
VirtualCityKe
 
MyCruise Qualitours - O site que você já conhece, agora pode ser SEU
MyCruise Qualitours - O site que você já conhece, agora pode ser SEUMyCruise Qualitours - O site que você já conhece, agora pode ser SEU
MyCruise Qualitours - O site que você já conhece, agora pode ser SEU
Qualitours
 
cv with portfolio set
cv with portfolio setcv with portfolio set
cv with portfolio set
Haseeb Ahmad
 
ใบงานที่ 10
ใบงานที่ 10ใบงานที่ 10
ใบงานที่ 10
Aungkana Na Na
 
Av01 gomezperla
Av01 gomezperlaAv01 gomezperla
Av01 gomezperla
perlart
 
New Farm Africa project to help boost grain trade across East Africa
New Farm Africa project to help boost grain trade across East AfricaNew Farm Africa project to help boost grain trade across East Africa
New Farm Africa project to help boost grain trade across East Africa
Milling and Grain magazine
 
Music genre
Music genreMusic genre
Music genre
TBaeM
 
Resume- Du Yaqiong
Resume- Du YaqiongResume- Du Yaqiong
Resume- Du Yaqiong
du yaqiong
 
ContinuousImprovement-certificate
ContinuousImprovement-certificateContinuousImprovement-certificate
ContinuousImprovement-certificate
Monique Bourgeois
 
GEODI : a Practical Information Management Solution For Construction Sector
GEODI : a Practical Information Management Solution For Construction SectorGEODI : a Practical Information Management Solution For Construction Sector
GEODI : a Practical Information Management Solution For Construction Sector
serdarak2
 
Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...
Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...
Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...
Carlos Sierra
 
Teorias del comercio internacional
Teorias del comercio internacionalTeorias del comercio internacional
Teorias del comercio internacional
Bernardo Zavahra
 
Ad

Similar to All on Adaptive and Extended Cursor Sharing (20)

Managing Statistics for Optimal Query Performance
Managing Statistics for Optimal Query PerformanceManaging Statistics for Optimal Query Performance
Managing Statistics for Optimal Query Performance
Karen Morton
 
Oracle 11g caracteristicas poco documentadas 3 en 1
Oracle 11g caracteristicas poco documentadas 3 en 1Oracle 11g caracteristicas poco documentadas 3 en 1
Oracle 11g caracteristicas poco documentadas 3 en 1
Ronald Francisco Vargas Quesada
 
SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?
Andrej Pashchenko
 
12c SQL Plan Directives
12c SQL Plan Directives12c SQL Plan Directives
12c SQL Plan Directives
Franck Pachot
 
OpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developersOpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developers
Connor McDonald
 
Oracle dbms_xplan.display_cursor format
Oracle dbms_xplan.display_cursor formatOracle dbms_xplan.display_cursor format
Oracle dbms_xplan.display_cursor format
Franck Pachot
 
Oracle 12c SPM
Oracle 12c SPMOracle 12c SPM
Oracle 12c SPM
Anton Bushmelev
 
On Seeing Double in V$SQL_Thomas_Kytepdf
On Seeing Double in V$SQL_Thomas_KytepdfOn Seeing Double in V$SQL_Thomas_Kytepdf
On Seeing Double in V$SQL_Thomas_Kytepdf
cookie1969
 
Writing efficient sql
Writing efficient sqlWriting efficient sql
Writing efficient sql
j9soto
 
Adapting to Adaptive Plans on 12c
Adapting to Adaptive Plans on 12cAdapting to Adaptive Plans on 12c
Adapting to Adaptive Plans on 12c
Mauro Pagano
 
11thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp0111thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp01
Karam Abuataya
 
A few things about the Oracle optimizer - 2013
A few things about the Oracle optimizer - 2013A few things about the Oracle optimizer - 2013
A few things about the Oracle optimizer - 2013
Connor McDonald
 
5 Cool Things About SQL
5 Cool Things About SQL5 Cool Things About SQL
5 Cool Things About SQL
Connor McDonald
 
Demystifying cost based optimization
Demystifying cost based optimizationDemystifying cost based optimization
Demystifying cost based optimization
Riyaj Shamsudeen
 
Dbms plan - A swiss army knife for performance engineers
Dbms plan - A swiss army knife for performance engineersDbms plan - A swiss army knife for performance engineers
Dbms plan - A swiss army knife for performance engineers
Riyaj Shamsudeen
 
SQLチューニング総合診療Oracle CloudWorld出張所
SQLチューニング総合診療Oracle CloudWorld出張所SQLチューニング総合診療Oracle CloudWorld出張所
SQLチューニング総合診療Oracle CloudWorld出張所
Hiroshi Sekiguchi
 
EvolveExecutionPlans.pdf
EvolveExecutionPlans.pdfEvolveExecutionPlans.pdf
EvolveExecutionPlans.pdf
PraveenPolu1
 
Do You Know The 11g Plan?
Do You Know The 11g Plan?Do You Know The 11g Plan?
Do You Know The 11g Plan?
Mahesh Vallampati
 
MV sql profile and index
MV sql profile and indexMV sql profile and index
MV sql profile and index
Heribertus Bramundito
 
Mod03 linking and accelerating
Mod03 linking and acceleratingMod03 linking and accelerating
Mod03 linking and accelerating
Peter Haase
 
Managing Statistics for Optimal Query Performance
Managing Statistics for Optimal Query PerformanceManaging Statistics for Optimal Query Performance
Managing Statistics for Optimal Query Performance
Karen Morton
 
SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?
Andrej Pashchenko
 
12c SQL Plan Directives
12c SQL Plan Directives12c SQL Plan Directives
12c SQL Plan Directives
Franck Pachot
 
OpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developersOpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developers
Connor McDonald
 
Oracle dbms_xplan.display_cursor format
Oracle dbms_xplan.display_cursor formatOracle dbms_xplan.display_cursor format
Oracle dbms_xplan.display_cursor format
Franck Pachot
 
On Seeing Double in V$SQL_Thomas_Kytepdf
On Seeing Double in V$SQL_Thomas_KytepdfOn Seeing Double in V$SQL_Thomas_Kytepdf
On Seeing Double in V$SQL_Thomas_Kytepdf
cookie1969
 
Writing efficient sql
Writing efficient sqlWriting efficient sql
Writing efficient sql
j9soto
 
Adapting to Adaptive Plans on 12c
Adapting to Adaptive Plans on 12cAdapting to Adaptive Plans on 12c
Adapting to Adaptive Plans on 12c
Mauro Pagano
 
11thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp0111thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp01
Karam Abuataya
 
A few things about the Oracle optimizer - 2013
A few things about the Oracle optimizer - 2013A few things about the Oracle optimizer - 2013
A few things about the Oracle optimizer - 2013
Connor McDonald
 
Demystifying cost based optimization
Demystifying cost based optimizationDemystifying cost based optimization
Demystifying cost based optimization
Riyaj Shamsudeen
 
Dbms plan - A swiss army knife for performance engineers
Dbms plan - A swiss army knife for performance engineersDbms plan - A swiss army knife for performance engineers
Dbms plan - A swiss army knife for performance engineers
Riyaj Shamsudeen
 
SQLチューニング総合診療Oracle CloudWorld出張所
SQLチューニング総合診療Oracle CloudWorld出張所SQLチューニング総合診療Oracle CloudWorld出張所
SQLチューニング総合診療Oracle CloudWorld出張所
Hiroshi Sekiguchi
 
EvolveExecutionPlans.pdf
EvolveExecutionPlans.pdfEvolveExecutionPlans.pdf
EvolveExecutionPlans.pdf
PraveenPolu1
 
Mod03 linking and accelerating
Mod03 linking and acceleratingMod03 linking and accelerating
Mod03 linking and accelerating
Peter Haase
 
Ad

Recently uploaded (20)

Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 

All on Adaptive and Extended Cursor Sharing

  • 1. 28/11/15 Mohamed Houri www.hourim.wordpress.com 1 Adaptive Cursor Sharing Short answer to sharing cursors and optimizing SQL Mohamed Houri www.hourim.wordpress.com Mohamed Houri www.hourim.wordpress.com
  • 2. 28/11/15 Mohamed Houri www.hourim.wordpress.com 2 Agenda Set the scene Expose the performance problem caused by sharing cursors Literal, bind variable, bind variable peeking and hard parsing Introduce Adaptive Cursor Sharing feature Adaptive Cursor Sharing Explain the cursor bind sensitive property Explain the cursor bind aware property Show a simple practical ACS example Explain the ACS monitoring v$sql views Uncover the bind aware secret sauce Show how ACS can introduce a serious perfomance issue Conclusion
  • 3. 28/11/15 Mohamed Houri www.hourim.wordpress.com 3 WHAT IS THE PROBLEM? PART 0 Set the scene
  • 4. 28/11/15 Mohamed Houri www.hourim.wordpress.com 4 Syntactic check Syntax, keywords Semantic check Access, right, exist Store parent cursor in v$sql(SGA) Logical Optimization Physical Optimization Store child cursor in v$sql(SGA) Parent cursor? Child cursor? Execute SQL No No Yes Yes Set the scene Hardparse Softparse
  • 5. 28/11/15 Mohamed Houri www.hourim.wordpress.com 5 Using Literal variable ➔ hard parsing for each execution ➔ traumatizes the SGA ➔ burns a lot CPU Set the scene Using bind variables ➔ avoids hard parsing ➔ makes the SGA attractive ➔ uses less resource - CPU generates “always“ an optimal plan sharing plan is not always optimal
  • 6. 28/11/15 Mohamed Houri www.hourim.wordpress.com 6 How to have best-of-both-world? Set the scene ➔ Attractive SGA + less CPU consumption ➔ Optimal execution plan for each execution Adaptive Cursor Sharing-ACS
  • 7. 28/11/15 Mohamed Houri www.hourim.wordpress.com 7 ACS - triggering diagram Invesigate this property
  • 8. 28/11/15 Mohamed Houri www.hourim.wordpress.com 8 WHEN A CURSOR IS BIND SENSITIVE? PART I ACS
  • 9. 28/11/15 Mohamed Houri www.hourim.wordpress.com 9 SQL> desc V$SQL Name Null? Type ------------------------------- -------- ------------- 1 SQL_TEXT VARCHAR2(1000) 2 SQL_FULLTEXT CLOB 3 SQL_ID VARCHAR2(13) 45 CHILD_NUMBER NUMBER 63 IS_OBSOLETE VARCHAR2(1) 64 IS_BIND_SENSITIVE VARCHAR2(1) 65 IS_BIND_AWARE VARCHAR2(1) 66 IS_SHAREABLE VARCHAR2(1) ACS - v$sql
  • 10. 28/11/15 Mohamed Houri www.hourim.wordpress.com 10 ACS – model SQL> create table t_acs(n1 number, n2 number); SQL> BEGIN for j in 1..1200150 loop if j = 1 then insert into t_acs values (j, 1); elsif j>1 and j<=101 then insert into t_acs values(j, 100); elsif j>101 and j<=1101 then insert into t_acs values (j, 1000); elsif j>10001 and j<= 110001 then insert into t_acs values(j,10000); else insert into t_acs values(j, 1000000); end if; end loop; commit; END; Inflexion point Inflexion point
  • 11. 28/11/15 Mohamed Houri www.hourim.wordpress.com 11 ACS – model SQL> create index t_acs_i1 on t_acs(n2); SQL> BEGIN dbms_stats.gather_table_stats (user ,'t_acs' ,method_opt => 'for all columns size 1' ,cascade => true ,estimate_percent => dbms_stats.auto_sample_size ); END; / –- declare and affect a value to a bind variable –- and run a query with range predicate SQL> var ln2 number; SQL> exec :ln2 := 100; Without histogram
  • 12. 28/11/15 Mohamed Houri www.hourim.wordpress.com 12 ACS – bind sensitive : range predicate SQL> select count(1) from t_acs where n2 <= :ln2; SQL> select sql_id ,child_number ,is_bind_sensitive from v$sql where sql_id = 'ct0yv82p15jdw'; SQL_ID CHILD_NUMBER IS_BIND_SENSITIVE ------------- ------------ ----------------- ct0yv82p15jdw 0 Y range predicate cursor is bind sensitive
  • 13. 28/11/15 Mohamed Houri www.hourim.wordpress.com 13 ACS – bind sensitive : equality predicate with histogram SQL> BEGIN dbms_stats.gather_table_stats (user,'t_acs' ,method_opt => 'for all columns size auto' ,cascade => true ,estimate_percent => dbms_stats.auto_sample_size); END;/ SQL> SELECT column_name, histogram FROM user_tab_col_statistics WHERE table_name = 'T_ACS' AND column_name = 'N2'; COLUMN_NAME HISTOGRAM ----------------- ----------- N2 FREQUENCY with histogram with histogram
  • 14. 28/11/15 Mohamed Houri www.hourim.wordpress.com 14 ACS – bind sensitive : equality predicate with histogram SQL> select count(1) from t_acs where n2 = :ln2; SQL> select sql_id ,child_number ,is_bind_sensitive from v$sql where sql_id = 'f2pmwazy1rnfd'; SQL_ID CHILD_NUMBER IS_BIND_SENSITIVE ------------- ------------ –----------------- f2pmwazy1rnfd 0 Y equality predicate with histogram cursor is bind sensitive
  • 15. 28/11/15 Mohamed Houri www.hourim.wordpress.com 15 ACS – bind sensitive : partition key SQL> create table t_acs_part(n1 number, n2 number) partition by range (n2) ( partition p1 values less than (100) ,partition p2 values less than (1000) ,partition p3 values less than (10000) ,partition p4 values less than (100000) ,partition p5 values less than (1000000) ,partition p6 values less than (10000000)); SQL> –- insert data and gather stats without histogram SQL> select column_name, histogram FROM user_tab_col_statistics where table_name = 'T_ACS_PART' AND column_name = 'N2'; COLUMN_NAM HISTOGRAM ---------- --------- N2 NONE
  • 16. 28/11/15 Mohamed Houri www.hourim.wordpress.com 16 ACS – bind sensitive : partition key SQL> select count(1) from t_acs where n2 = :ln2; SQL> select sql_id ,child_number ,is_bind_sensitive from v$sql where sql_id = 'byztzuffb65n9'; SQL_ID CHILD_NUMBER IS_BIND_SENSITIVE ------------- ------------ –---------------- byztzuffb65n9 0 Y partition key cursor is bind sensitive
  • 17. 28/11/15 Mohamed Houri www.hourim.wordpress.com 17 ACS – bind sensitive : summary range predicate (with simple statistics) SQL> select count(1) from t_acs where n2 <= :ln2; equality predicate (with histogram) SQL> select count(1) from t_acs where n2 = :ln2; predicate with partition key (simple stats) SQL> select count(1) from t_acs where n2 = :ln2;
  • 18. 28/11/15 Mohamed Houri www.hourim.wordpress.com 18 18 PART II ACS-simple example A SIMPLE ACS EXAMPLE
  • 19. 28/11/15 Mohamed Houri www.hourim.wordpress.com 19 ACS-simple example SQL> exec :ln2 := 100 SQL> select count(1) from t_acs where n2 = :ln2; SQL> select n2,count(1) from t_acs group by n2 order by 2; N2 COUNT(1) ---------- ---------- 1 1 100 100 1000 1000 10000 100000 1000000 1099049 index range scan full table scan
  • 20. 28/11/15 Mohamed Houri www.hourim.wordpress.com 20 ACS-simple example SQL_ID f2pmwazy1rnfd, child number 0 ----------------------------------------------------- | Id | Operation | Name | Rows | Bytes | ----------------------------------------------------- | 0 | SELECT STATEMENT | | | | | 1 | SORT AGGREGATE | | 1 | 3 | |* 2 | INDEX RANGE SCAN| T_ACS_I1 | 856 | 2568 | ----------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - access("N2"=:LN2) optimal plan for the first execution. Plan has been hard parsed
  • 21. 28/11/15 Mohamed Houri www.hourim.wordpress.com 21 ACS-simple example SQL> exec :ln2 := 1000000 –- 1st execution with bind variable value = 1000000 SQL> select count(1) from t_acs where n2 = :ln2; SQL_ID f2pmwazy1rnfd, child number 0 ----------------------------------------------------- | Id | Operation | Name | Rows | Bytes | ----------------------------------------------------- | 0 | SELECT STATEMENT | | | | | 1 | SORT AGGREGATE | | 1 | 3 | |* 2 | INDEX RANGE SCAN| T_ACS_I1 | 856 | 2568 | ----------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - access("N2"=:LN2) sharing plan is bad here
  • 22. 28/11/15 Mohamed Houri www.hourim.wordpress.com 22 ACS-simple example SQL> exec :ln2 := 1000000 –- 2nd execution with bind variable value = 1000000 SQL> select count(1) from t_acs where n2 = :ln2; SQL_ID f2pmwazy1rnfd, child number 1 ----------------------------------------------------- | Id | Operation | Name | Rows | Bytes | ----------------------------------------------------- | 0 | SELECT STATEMENT | | | | | 1 | SORT AGGREGATE | | 1 | 3 | |* 2 | TABLE ACCESS FULL| T_ACS | 1104K| 3235K| ----------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 – filter("N2"=:LN2) optimal plan at the second execution
  • 23. 28/11/15 Mohamed Houri www.hourim.wordpress.com 23 ACS-simple example –- back to the first bind variable value 100 SQL> exec :ln2 := 100 SQL> select count(1) from t_acs where n2 = :ln2; SQL_ID f2pmwazy1rnfd, child number 2 ------------------------------------------------------ | Id | Operation | Name | Rows | Bytes | ------------------------------------------------------ | 0 | SELECT STATEMENT | | | | | 1 | SORT AGGREGATE | | 1 | 3 | |* 2 | INDEX RANGE SCAN| T_ACS_I1 | 1713 | 5139 | ------------------------------------------------------ Predicate Information (identified by operation id): --------------------------------------------------- 2 – access("N2"=:LN2) execution plan is now immediately optimal
  • 24. 28/11/15 Mohamed Houri www.hourim.wordpress.com 24 SQL> select sql_id ,child_number ,is_bind_sensitive ,is_bind_aware from v$sql where sql_id = 'f2pmwazy1rnfd'; SQL_ID CHILD_NUMBER IS_BIND_SENS IS_BIND_AWARE ------------- ------------ –----------- –------------- f2pmwazy1rnfd 0 Y N → index-RS f2pmwazy1rnfd 1 Y Y → table-FS f2pmwazy1rnfd 2 Y Y → index-RS is that cursor is now bind aware what happens? ACS-simple example
  • 25. 28/11/15 Mohamed Houri www.hourim.wordpress.com 25 ACS-simple example We have gone wrong(index range scan plan shared) during the first execution with :ln2 := 1000000 It is until the second execution with :ln2 := 1000000 that Oracle has compiled a new optimal plan (full table scan) We have to share the “wrong” plan during a certain number of executions This “certain number” of executions is strongly related to the number of executions done at the initial bind variable value :ln2 := 100 This execution-count relationship will be explained later (BUCKET_ID, COUNT)
  • 26. 28/11/15 Mohamed Houri www.hourim.wordpress.com 26 26 PART III ACS-bind aware secret sauce When Oracle decides that it is time to compile a new execution plan?
  • 27. 28/11/15 Mohamed Houri www.hourim.wordpress.com 27 27 SQL> desc V$SQL_CS_STATISTICS Name Null? Type ------------------------------- -------- -------------- 1 ADDRESS RAW(8) 2 HASH_VALUE NUMBER 3 SQL_ID VARCHAR2(13) 4 CHILD_NUMBER NUMBER 5 BIND_SET_HASH_VALUE NUMBER 6 PEEKED VARCHAR2(1) 7 EXECUTIONS NUMBER 8 ROWS_PROCESSED NUMBER 9 BUFFER_GETS NUMBER 10 CPU_TIME NUMBER 11 CON_ID NUMBER ACS-bind aware secret sauce Starting from 12c this view is obsolete
  • 28. 28/11/15 Mohamed Houri www.hourim.wordpress.com 28 28 SQL> desc V$SQL_CS_HISTOGRAM Name Null? Type ------------------------------- -------- ------------- 1 ADDRESS RAW(8) 2 HASH_VALUE NUMBER 3 SQL_ID VARCHAR2(13) 4 CHILD_NUMBER NUMBER 5 BUCKET_ID NUMBER 6 COUNT NUMBER 7 CON_ID NUMBER ACS-bind aware secret sauce number of executions done at this child_number linked to the number of rows processed by this child_number
  • 29. 28/11/15 Mohamed Houri www.hourim.wordpress.com 29 29 SQL> desc V$SQL_CS_SELECTIVITY Name Null? Type ----------------------- -------- -------------- 1 ADDRESS RAW(8) 2 HASH_VALUE NUMBER 3 SQL_ID VARCHAR2(13) 4 CHILD_NUMBER NUMBER 5 PREDICATE VARCHAR2(40) 6 RANGE_ID NUMBER 7 LOW VARCHAR2(10) 8 HIGH VARCHAR2(10) 9 CON_ID NUMBER ACS-bind aware secret sauce This view becomes useful only when cursor is bind aware
  • 30. 28/11/15 Mohamed Houri www.hourim.wordpress.com 30 30 ACS-bind aware secret sauce 0 <= ROWS_PROCESSED< 1,000 increments COUNT of BUCKET_ID n° 0 1,000 <= ROWS_PROCESSED<= 1,000,000 increments COUNT of BUCKET_ID n° 1 ROWS_PROCESSED> 1,000,000 increments COUNT of BUCKET_ID n° 2 Inflexion point Inflexion point
  • 31. 28/11/15 Mohamed Houri www.hourim.wordpress.com 31 SQL> exec :ln2 := 100 –- 1st execution with this value SQL> select count(1) from t_acs where n2 = :ln2; COUNT(1) ---------- 100 ACS-bind aware secret sauce Nbr of rows processed <1000 SQL> select child_number,bucket_id,count from v$sql_cs_histogram where sql_id = 'f2pmwazy1rnfd' ; CHILD_NUMBER BUCKET_ID COUNT ------------ ---------- ---------- 0 0 1 0 1 0 0 2 0 count(bucket_id n°0) incremented
  • 32. 28/11/15 Mohamed Houri www.hourim.wordpress.com 32 SQL> exec :ln2 := 100 –- 2nd execution with this value SQL> select count(1) from t_acs where n2 = :ln2; COUNT(1) ---------- 100 ACS-bind aware secret sauce SQL> select child_number,bucket_id,count from v$sql_cs_histogram where sql_id = 'f2pmwazy1rnfd' ; CHILD_NUMBER BUCKET_ID COUNT ------------ ---------- ---------- 0 0 2 0 1 0 0 2 0 count(bucket_id n°0) incremented Nbr of rows processed <1000
  • 33. 28/11/15 Mohamed Houri www.hourim.wordpress.com 33 SQL> exec :ln2 := 100 –- 3rd execution with this value SQL> select count(1) from t_acs where n2 = :ln2; COUNT(1) ---------- 100 ACS-bind aware secret sauce SQL> select child_number,bucket_id,count from v$sql_cs_histogram where sql_id = 'f2pmwazy1rnfd' ; CHILD_NUMBER BUCKET_ID COUNT ------------ ---------- ---------- 0 0 3 0 1 0 0 2 0 count(bucket_id n°0) incremented Nbr of rows processed <1000
  • 34. 28/11/15 Mohamed Houri www.hourim.wordpress.com 34 SQL> exec :ln2 := 1000 –- 1st execution with this value SQL> select count(1) from t_acs where n2 = :ln2; COUNT(1) ------- 1000 ACS-bind aware secret sauce SQL> select child_number,bucket_id,count from v$sql_cs_histogram where sql_id = 'f2pmwazy1rnfd' ; CHILD_NUMBER BUCKET_ID COUNT ------------ ---------- ---------- 0 0 3 0 1 1 0 2 0 count(bucket_id n°1) incremented 1000<= Nbr of rows processed <= 1e6 still sharing same plan
  • 35. 28/11/15 Mohamed Houri www.hourim.wordpress.com 35 SQL> exec :ln2 := 1000 –-2nd execution with this value SQL> select count(1) from t_acs where n2 = :ln2; COUNT(1) ------- 1000 ACS-bind aware secret sauce SQL> select child_number,bucket_id,count from v$sql_cs_histogram where sql_id = 'f2pmwazy1rnfd' ; CHILD_NUMBER BUCKET_ID COUNT ------------ ---------- ---------- 0 0 3 0 1 2 0 2 0 count(bucket_id n°1) incremented 1000<= Nbr of rows processed <= 1e6 still sharing same plan
  • 36. 28/11/15 Mohamed Houri www.hourim.wordpress.com 36 SQL> exec :ln2 := 1000 –-3rd execution with this value SQL> select count(1) from t_acs where n2 = :ln2; COUNT(1) ------- 1000 ACS-bind aware secret sauce SQL> select child_number,bucket_id,count from v$sql_cs_histogram where sql_id = 'f2pmwazy1rnfd' ; CHILD_NUMBER BUCKET_ID COUNT ------------ ---------- ---------- 0 0 3 0 1 3 0 2 0 count(bucket_id n°1) incremented 1000<= Nbr of rows processed <= 1e6 still sharing same plan
  • 37. 28/11/15 Mohamed Houri www.hourim.wordpress.com 37 SQL> exec :ln2 := 1000 –-4th execution with this value SQL> select count(1) from t_acs where n2 = :ln2; ACS-bind aware secret sauce SQL> select child_number,bucket_id,count from v$sql_cs_histogram where sql_id = 'f2pmwazy1rnfd' ; CHILD_NUMBER BUCKET_ID COUNT ------------ ---------- ---------- 1 0 0 1 1 1 1 2 0 0 0 3 0 1 3 0 2 0 count(bucket_id n°1) incremented new compiled plan
  • 38. 28/11/15 Mohamed Houri www.hourim.wordpress.com 38 SQL> select sql_id ,child_number ,is_bind_sensitive ,is_bind_aware from v$sql where sql_id = 'f2pmwazy1rnfd'; SQL_ID CHILD_NUMBER IS_BIND_SENS IS_BIND_AWARE ------------- ------------ –----------- –------------- f2pmwazy1rnfd 0 Y N f2pmwazy1rnfd 1 Y Y cursor n° 1 is now bind aware ACS-bind aware secret sauce
  • 39. 28/11/15 Mohamed Houri www.hourim.wordpress.com 39 39 ACS-bind aware secret sauce – rule n° 1 : adjacent buckets COUNT(BUCKET_ID n° 1) = COUNT(BUCKET_ID n° 0) OR COUNT(BUCKET_ID n° 2) = COUNT(BUCKET_ID n° 1) The next execution at BUCKET_ID n°1 (or n°2) will  mark the cursor bind aware  and a new execution plan will be compiled
  • 40. 28/11/15 Mohamed Houri www.hourim.wordpress.com 40 SQL> exec :ln2 := 100 –- bucket_id n° 0 SQL> select count(1) from t_acs where n2 = :ln2; SQL> ../.. 10 executions ACS-bind aware secret sauce : distant bucket_id SQL> select child_number,bucket_id,count from v$sql_cs_histogram where sql_id = 'f2pmwazy1rnfd' ; CHILD_NUMBER BUCKET_ID COUNT ------------ ---------- ---------- 0 0 10 0 1 0 0 2 0 count(bucket_id n°0) Incremented 10 times
  • 41. 28/11/15 Mohamed Houri www.hourim.wordpress.com 41 SQL> exec :ln2 := 1000000 –- bucket_id n°2 SQL> select count(1) from t_acs where n2 = :ln2; COUNT(1) ---------- 1099049 ACS-bind aware secret sauce : distant bucket_id SQL> select child_number,bucket_id,count from v$sql_cs_histogram where sql_id = 'f2pmwazy1rnfd' ; CHILD_NUMBER BUCKET_ID COUNT ------------ ---------- ---------- 0 0 10 0 1 0 0 2 1 count(bucket_id n°2) Incremented 1 time still sharing same plan Nbr of rows > 1e6
  • 42. 28/11/15 Mohamed Houri www.hourim.wordpress.com 42 Question : How many executions at bucket_id n°2 we need to have before Oracle compile a new optimal plan? ACS-bind aware secret sauce : distant bucket_id –- run this 3 times SQL> select count(1) from t_acs where n2 = :ln2; SQL> select child_number,bucket_id,count from v$sql_cs_histogram where sql_id = 'f2pmwazy1rnfd' ; CHILD_NUMBER BUCKET_ID COUNT ------------ ---------- ---------- 0 0 10 0 1 0 0 2 4 count(bucket_id n°2) incremented 3 times Answer : 4 executions still sharing the same plan
  • 43. 28/11/15 Mohamed Houri www.hourim.wordpress.com 43 SQL> exec :ln2 := 1000000 –-5th execution at this value SQL> select count(1) from t_acs where n2 = :ln2; SQL> select child_number,bucket_id,count from v$sql_cs_histogram where sql_id = 'f2pmwazy1rnfd' ; CHILD_NUMBER BUCKET_ID COUNT ------------ ---------- ---------- 1 0 0 1 1 0 1 2 1 0 0 10 0 1 0 0 2 4 10 exec at bucket_id n°0 new compiled plan ACS-bind aware secret sauce : distant bucket_id 4 exec at bucket_id n°2
  • 44. 28/11/15 Mohamed Houri www.hourim.wordpress.com 44 44 4 = ceil (10/3) The next execution at BUCKET_ID n°2 will  mark the cursor bind aware  and a new execution plan will be compiled ACS-bind aware secret sauce : distant bucket_id Applies only with distant bucket_id (0 and 2) COUNT(BUCKET_ID n° 2) = ceil (COUNT(BUCKET_ID n° 0)/3)
  • 45. 28/11/15 Mohamed Houri www.hourim.wordpress.com 45 ACS-bind aware secret sauce : all buckets involved SQL> select child_number,bucket_id,count from v$sql_cs_histogram where sql_id = 'f2pmwazy1rnfd' ; CHILD_NUMBER BUCKET_ID COUNT ------------ ---------- ---------- 0 0 10 0 1 3 0 2 1 Question : How many executions at bucket_id n°2 we need to have before Oracle compiles a new optimal plan? 10 exec at bucket_id n°0 3 exec at bucket_id n°1 1 exec at bucket_id n°2
  • 46. 28/11/15 Mohamed Houri www.hourim.wordpress.com 46 ACS-bind aware secret sauce : all buckets involved ------------------------------------------------------------------------------ -- File name: fv_will_cs_be_bind_aware -- Author : Mohamed Houri ([email protected]) -- Date : 29/08/2015 -- Purpose : When supplied with 3 parameters -- pin_cnt_bucket_0 : count of bucket_id n°0 -- pin_cnt_bucket_1 : count of bucket_id n°1 -- pin_cnt_bucket_2 : count of bucket_id n°2 -- this function will return a status: -- 'Y' if the next execution at any bucket_id will mark the cursor bind aware -- 'N' if the next execution any bucket_id will NOT mark the cursor bind aware -------------------------------------------------------------------------------- create or replace function fv_will_cs_be_bind_aware (pin_cnt_bucket_0 in number,pin_cnt_bucket_1 in number,pin_cnt_bucket_2 in number) return varchar2 is lv_will_be_bind_aware varchar2(1) := 'N'; ln_least_0_2 number := least(pin_cnt_bucket_0,pin_cnt_bucket_2); ln_great_0_2 number := greatest(pin_cnt_bucket_0,pin_cnt_bucket_2); begin if pin_cnt_bucket_0 + pin_cnt_bucket_2 > = pin_cnt_bucket_1 and ln_least_0_2 >= ceil ((ln_great_0_2-pin_cnt_bucket_1)/3)then return 'Y'; else return 'N'; end if; end fv_will_cs_be_bind_aware;
  • 47. 28/11/15 Mohamed Houri www.hourim.wordpress.com 47 ACS-bind aware secret sauce : all buckets involved SQL> select child_number,bucket_id,count from v$sql_cs_histogram where sql_id = 'f2pmwazy1rnfd' ; CHILD_NUMBER BUCKET_ID COUNT ------------ ---------- ---------- 0 0 10 0 1 3 0 2 1 SQL> select fv_will_cs_be_bind_aware(10,3,1) acs from dual; ACS ---- N next execution will share the same plan
  • 48. 28/11/15 Mohamed Houri www.hourim.wordpress.com 48 SQL> exec :ln2 := 1000000 –- 2nd execution at this value SQL> select count(1) from t_acs where n2 = :ln2; SQL> select child_number,bucket_id,count from v$sql_cs_histogram where sql_id = 'f2pmwazy1rnfd' ; CHILD_NUMBER BUCKET_ID COUNT ------------ ---------- ---------- 0 0 10 0 1 3 0 2 2 SQL> select fv_will_cs_be_bind_aware(10,3,2) acs from dual; ACS ---- N next execution will share the same plan ACS-bind aware secret sauce : all buckets involved
  • 49. 28/11/15 Mohamed Houri www.hourim.wordpress.com 49 SQL> exec :ln2 := 1000000 –- 3rd execution at this value SQL> select count(1) from t_acs where n2 = :ln2; SQL> select child_number,bucket_id,count from v$sql_cs_histogram where sql_id = 'f2pmwazy1rnfd' ; CHILD_NUMBER BUCKET_ID COUNT ------------ ---------- ---------- 0 0 10 0 1 3 0 2 3 SQL> select fv_will_cs_be_bind_aware(10,3,3) acs from dual; ACS ---- Y next execution will compile a new plan ACS-bind aware secret sauce : all buckets involved
  • 50. 28/11/15 Mohamed Houri www.hourim.wordpress.com 50 SQL> exec :ln2 := 1000000 –- 4th execution at this value SQL> select count(1) from t_acs where n2 = :ln2; SQL> select child_number,bucket_id,count from v$sql_cs_histogram where sql_id = 'f2pmwazy1rnfd' ; CHILD_NUMBER BUCKET_ID COUNT ------------ ---------- ---------- 1 0 0 1 1 0 1 2 1 0 0 10 0 1 3 0 2 3 new execution plan compiled ACS-bind aware secret sauce : all buckets involved
  • 51. 28/11/15 Mohamed Houri www.hourim.wordpress.com 51 51 The next exection at any BUCKET will  mark the cursor bind aware  and a new execution plan will be compiled SQL> select fv_will_cs_be_bind_aware (pin_cnt_bucket_0 ,pin_cnt_bucket_1 ,pin_cnt_bucket_2 ) from dual; Existing plan will be shared N Y Not extensively tested!!! ACS-bind aware secret sauce : all buckets involved
  • 52. 28/11/15 Mohamed Houri www.hourim.wordpress.com 52 52 ACS-bind aware secret sauce : summary COUNT(BUCKET_ID 1) = COUNT(BUCKET_ID 0) ADJACENT BUCKET_ID (0-1 or 1-2) next execution will compile a new execution plan COUNT(BUCKET_ID 2) = CEIL(COUNT(BUCKET_ID 0) /3) next execution will compile a new execution plan DISTANT BUCKET_ID (0-2) select fv_will_cs_be_bind_aware (0,1,2) from dual; → Y next execution will compile a new execution plan ALL BUCKET_ID involved
  • 53. 28/11/15 Mohamed Houri www.hourim.wordpress.com 53 53 PART IV Extended Cursor Sharing Extended Cursor Sharing- ECS
  • 54. 28/11/15 Mohamed Houri www.hourim.wordpress.com 54 54 Extended Cursor Sharing Adaptive Cursor Sharing Extended Cursor Sharing is responsible for marking bind aware a bind sensitive cursor provided one of the 3 rules is satisfied is responsible for checking if an execution plan of a bind aware cursor has to be shared or a new plan has to be compiled according to the bind variable selectivity it peeks at each execution
  • 55. 28/11/15 Mohamed Houri www.hourim.wordpress.com 55 SQL> select sql_id ,child_number ,is_bind_sensitive ,is_bind_aware from v$sql where sql_id = 'f2pmwazy1rnfd'; SQL_ID CHILD_NUMBER IS_BIND_SENS IS_BIND_AWARE ------------- ------------ –----------- –------------- f2pmwazy1rnfd 0 Y N f2pmwazy1rnfd 1 Y Y once a cursor is bind aware a row exists in v$sql_cs_selectivity Extended Cursor Sharing
  • 56. 28/11/15 Mohamed Houri www.hourim.wordpress.com 56 SQL> select child_number ,predicate ,low ,high From v$sql_cs_selectivity where sql_id = 'f2pmwazy1rnfd'; CHILD_NUMBER PREDICATE LOW HIGH ------------ ------------- ---------- ---------- 2 =LN2 0.827448 1.011325 1 =LN2 0.000807 0.000986 Extended Cursor Sharing for each execution bind variable selectivity is checked: if it exists in one of the LOW-HIGH ranges then share plan. If not then compile a new plan and insert/update a new LOW-HIGH range this is ECS
  • 57. 28/11/15 Mohamed Houri www.hourim.wordpress.com 57 57 PART V Extended Cursor Sharing causing a performance issue When ACS (in fact ECS) becomes a serious performance threat
  • 58. 28/11/15 Mohamed Houri www.hourim.wordpress.com 58 SQL> select sql_id ,count(1) from v$sql where executions < 2 group by sql_id having count(1) > 10 order by 2 desc; SQL_ID COUNT(1) ------------- ---------- 7zwq7z1nj7vga 44217 Extended Cursor Sharing causing a performance issue Why this high nbr of versions?
  • 59. 28/11/15 Mohamed Houri www.hourim.wordpress.com 59 SQL> @nonshared 7zwq7z1nj7vga Show why existing SQL child cursors were not reused(V$SQL_SHARED_CURSOR) ----------------- SQL_ID : 7zwq7z1nj7vga ADDRESS : 000000406DBB30F8 CHILD_ADDRESS : 00000042CE36F7E8 CHILD_NUMBER : 99 BIND_EQUIV_FAILURE : Y REASON :<ChildNode><ChildNumber>0</ChildNumber><ID>40</ID> <reason>Bindmismatch(33)</reason><size>2x4</size> <init_ranges_in_first_pass>0</init_ranges_in_first_pass> <selectivity>1097868685</selectivity> </ChildNode> Extended Cursor Sharing causing a performance issue 100 exec plans (0-99) due to bind_equivalent_failure
  • 60. 28/11/15 Mohamed Houri www.hourim.wordpress.com 60 SQL> select count(1) from v$sql_shared_cursor Where sql_id = '7zwq7z1nj7vga'; COUNT(1) ---------- 45125 SQL> select count(1) from v$sql_shared_cursor Where sql_id = '7zwq7z1nj7vga' and BIND_EQUIV_FAILURE = 'Y'; COUNT(1) ---------- 45121 99% of non shared cursors are due to BIND_EQUIV_FAILURE Extended Cursor Sharing causing a performance issue
  • 61. 28/11/15 Mohamed Houri www.hourim.wordpress.com 61 BIND_EQUIV_FAILURE : bind value's selectivity does not match that used to optimize the existing child cursor SQL> select count(1) from v$sql_cs_selectivity where sql_id = '7zwq7z1nj7vga'; COUNT(1) ---------- 16,847,320 !!! for each execution ECS will check this view!!! Extended Cursor Sharing causing a performance issue CHILD_NUMBER PREDICATE LOW HIGH ------------ ------------- ---------- ---------- 2 =LN2 0.827448 1.011325
  • 62. 28/11/15 Mohamed Houri www.hourim.wordpress.com 62 Extended Cursor Sharing causing a performance issue Run a query using a bind aware cursor Oracle (ECS layer code) will do behind the scene: 1. peeks at the bind variable value 2. runs a query against v$sql_cs_selectivity(16M of rows) 3. if low < selectivity < high then share existing plan 4. if selectity not found in low-high range then hard parse a new plan If another user executes the same query: 1. Oracle will try to do the above 1-4 steps 2. if Oracle is still busy with above 1-4 steps then we start experiencing: a) cursor: pin S wait on X b) library cache lock
  • 63. 28/11/15 Mohamed Houri www.hourim.wordpress.com 63 63 PART V Adaptive-Extended Cursor Sharing FINAL ACS-ECS DIAGRAM https://hourim.wordpress.com/2015/08/12/adaptive-cursor-sharing-triggering-mechanism/
  • 64. 28/11/15 Mohamed Houri www.hourim.wordpress.com 64 64 Adaptive Cursor Sharing •Conclusion • Literal variables are good for query performance • very bad for resource and memory • and they produce a non scalable application • Bind variables are not always good for query performance • very good for resource and memory • and they produce a scalable application • Adaptive cursor sharing allows query good performance • even when using bind variable • but be aware of the extra parsing work it might introduce