Be A Hero in SQL Tuning
Be A Hero in SQL Tuning
V.Hariharaputhran
www.puthranv.com
V.Hariharaputhran
o Twelve years in Oracle Development / DBA / Big Data /
Cloud Technologies
o All India Oracle Users Group (AIOUG) Evangelist
o Passion to learn and share
o Blog: www.puthranv.com
www.puthranv.com
o Twitter: @puthranv
How to start
What should I know
What tool to use when
www.puthranv.com
Cardinality
Feedback
Histograms
Clustering Factor
Outlines
SQL Profiles
Hints
In-memory
Index
Partitions
www.puthranv.com
10:00 SQL - A
10:05 SQL - A
INDEX
06 ms
02.82 s
11:19 SQL - A
11:17 SQL - A
FTS
21 ms
85 ms
www.puthranv.com
Hard Parse
Select * from tbl where col = 22
4
3
Memory
2 (Library Cache)
1
Library Cache Contention
library cache: mute x
Lath: shared pool
www.puthranv.com
Literals
Select * from tbl where col = 22
Select * from tbl where col = 20
Select * from tbl where col = 10
Select * from tbl where col = 2
Select * from tbl where col = 2
Binds
Issue Resolved ?
www.puthranv.com
Literals - BAD
Select * from tbl where col = 22
Binds - Good
Select * from tbl where col = :v1
Soft Parse
Cursor is Sharable
Avoid Library Cache
Contention
Hit on CPU is minimized
Application is Scalable
www.puthranv.com
www.puthranv.com
www.puthranv.com
www.puthranv.com
10:00 SQL - A
10:05 SQL - A
20000
INDEX
06 ms
02.82 s
22
20000
11:19 SQL - A
11:17 SQL - A
FTS
21 ms
85 ms
www.puthranv.com
Literals
Select * from tbl where col = 22
1. Hard Parse
1. Execution Plan No Shared
2. Cardinality Estimate based
on Literals
3. Cardinality Feedback is
used
4. Histograms info are Visible
Binds
Select * from tbl where col = :v1
1. Soft Parse
1. Execution Plan Shared
2. Cardinality Estimate on binds
ONLY FIRST TIME (until 10g)
3. Cardinality Feedback feature
does not work with binds
4. Binds and Histograms does not
go well
www.puthranv.com
www.puthranv.com
Optimizer - ACS
22
10
Run
Sensitive
Aware
Parse
SQL ID
Child No
Access
Hard
ASQL1
Index
Run
Sensitive
Aware
Parse
SQL ID
Child No
Access
Soft
ASQL1
Index
Product_id = :v1
20000
Run
Sensitive
Aware
Parse
SQL ID
Child No
Access
Hard
ASQL1
FTS
www.puthranv.com
20000
20000
10:00 SQL - A
10:05 SQL - A
10:15 SQL - A
10:20 SQL - A
INDEX
FTS
06 ms
02.82 s
04 ms
85 ms
www.puthranv.com
12c
Optimizer Evolution
11g
10g
9i
SQL Profiles
8i
Bind Peeking
Cursor Sharing
No Bind Peeking
www.puthranv.com
Thanks
www.puthranv.com