Why You May Not Need Offloading
January 20, 2013
Presented by: Alex Fatkulin
Senior Consultant
Who am I ?
Senior Technical Consultant at Enkitec
12 years using Oracle
Clustered and HA solutions
Database Development and Design
Technical Reviewer
Blog at http://afatkulin.blogspot.com
3
Why This Presentation?
4
Sounds familiar? (tongue in cheek)
My SQL is slow but itβs offload ratio is 95%+
This just canβt be!
My SQL is slow and it must be because it has a low
offload ratio
This ought to be it!
Offload ratio is the only thing to worry about
Nothing else matters!
5
What is offload ratio?
The amount of work performed on the storage cells
relative to the total amount of work
6
π = π(πΆπΈπΏπΏ)
π πΆπΈπΏπΏ + π(π π·π΅ππ)
I/O Saved (MOS)
MOS Doc ID 1438173.1
7
πΌπ_ππ΄ππΈπ· =πΌπ_πΆπΈπΏπΏ_ππΉπΉπΏππ΄π·_πΈπΏπΌπΊπΌπ΅πΏπΈ_π΅πππΈπ β πΌπ_πΌπππΈπ πΆππππΈπΆπ_π΅πππΈπ
πΌπ_πΆπΈπΏπΏ_ππΉπΉπΏππ΄π·_πΈπΏπΌπΊπΌπ΅πΏπΈ_π΅πππΈπ
= 1 β πΌπ_πΌπππΈπ πΆππππΈπΆπ_π΅πππΈπ
πΌπ_πΆπΈπΏπΏ_ππΉπΉπΏππ΄π·_πΈπΏπΌπΊπΌπ΅πΏπΈ_π΅πππΈπ
IO_INTERCONNECT_BYTES
Includes all types of I/O against any storage
Includes mirrored data
Compressed vs Uncompressed data
Cell Offload Efficiency (SQLMON)
SQL Monitor
8
C = 1 β πΌπ_πΌπππΈπ πΆππππΈπΆπ_π΅πππΈπ
ππ»πππΌπΆπ΄πΏ_π πΈπ΄π·_π΅πππΈπ + ππ»πππΌπΆπ΄πΏ_ππ πΌππΈ_π΅πππΈπ
Only considers data volumes
Offload Ratio
Two SQL statements return the same data but have
different plans and offload ratios
9
SQL Statement Offload ratio
A 90%
B 0%
Which one is better?
Offload Ratio
Two SQL statements return the same data but have
different plans and offload ratios
10
SQL Statement Offload ratio Scanned Returned
A 90% 100GB 10GB
B 0% 10GB 10GB
Using offload ratio alone is unreliable indicator for
performance
90% Offload Ratio
11
SELECT * FROM TRANS_DATA WHERE STATE=βNJβ
RDBMS
100%
CELLSRV
10% (STATE=βNJβ)
90% Offload Ratio
12
SELECT * FROM TRANS_DATA WHERE STATE=βNJβ
CELLSRV
10%
100%
DISCARDED 90%
RDBMS
90% Offload Ratio
13
SELECT * FROM TRANS_DATA WHERE STATE=βNJβ
CELLSRV
10%
(output)
100% (input)
DISCARDED 90%
(overhead)
RDBMS
Offload Ratio
14
create table trans_data
(
...
state varchar2(2),
...
) partition by list (state)
(
...
partition NJ values ('NJ'),
partition NY values ('NY'),
...
);
What if we partition the table?
0% Offload Ratio
15
SELECT * FROM TRANS_DATA WHERE STATE=βNJβ
CELLSRV
100% (input)
NOTHING DISCARDED 0%
(overhead)
RDBMS
100%
(output)
Eliminated by Partition Pruning
Cell Offload Efficiency (SQLMON)
16
Efficiency
Overhead
C = 1 β πΌπ_πΌπππΈπ πΆππππΈπΆπ_π΅πππΈπ
ππ»πππΌπΆπ΄πΏ_π πΈπ΄π·_π΅πππΈπ + ππ»πππΌπΆπ΄πΏ_ππ πΌππΈ_π΅πππΈπ
β 1 βOUTPUT
INPUT
SELECT * FROM TRANS_DATA WHERE STATE=βNJβ
Data Selectivity
Selective data β data SQL statement needs for the final
result
Unselective data β data SQL statement has to go through
17
SQL Input Output Data Selectivity
A 100GB 10GB 10%
B 10GB 10GB 100%
Data Selectivity and Exadata
Data selective query beats data unselective query any day of the
week (all other things equal)
Data unselective queries tend to benefit the most from the Exadata
18
0 10 20 30 40 50 60 70 80 90 100
SQL B
SQL B Exadata
SQL A
SQL A Exadata
Response Time %
Unselective Data Selective Data
Exadata Design Disaster
The easiest way to archive high offload ratios is to make
all your SQLs to be very data unselective
19
The Year is 2001β¦
20
The Year is 2001β¦
βBuffer Cache Hit Ratio Tuning is
Rampantβ¦β
21
The Year is 2001β¦
Why a 99%+ Database Buffer Cache Hit Ratio is NOT Ok (*)
Cary Millsap/Hotsos Enterprises Ltd.
22
(*) used here with Caryβs permission
The Year is 2001β¦
βDatabase buffer cache hit ratios are
useless!!!β
23
Buffer Cache Hit Ratio
One of the major ratios used to tune databases
Displayed on the βfront pageβ of most database tools
(Quest Spotlight, Oracle OEM, etc.)
Choose any hit ratio (why BCHR is useless):
http://www.oracledba.co.uk/tips/choose.htm
It took 10+ years to deal with it
24
Bump Your Offload Ratio If youβre still unconvincedβ¦
25
Bump Your Offload Ratio
Improves your offload ratio to 99%+ percent!!! (*)
26
--One time setup
create table bump_my_offload nocompress as
select rpad('x', 4000, 'x') x
from dual
connect by level <= 200000;
--Main Loop
begin
execute immediate 'alter session set parallel_degree_policy=manual';
execute immediate 'alter session set "_parallel_cluster_cache_policy"=adaptive';
execute immediate 'alter session set "_kcfis_storageidx_disabled"=true';
loop
for cur in (select /*+ parallel(16) */ * from bump_my_offload where x is null)
loop
null;
end loop;
end loop;
end;
(*) if you donβt archive 99%+ offload ratio simply run more
copies of the βMain Loopβ in parallel
Limitations
27
Data Processing
28
SELECT STATE, STORE_ID, DATE_ID, SUM(AMOUNT), COUNT(DISTINCT CART_ID)
FROM TRANS_DATA
GROUP BY STATE, STORE_ID, DATE_ID
CPU User I/O
Raw Data Processing
Aggregation
Processing Raw Data Processing Exadata
Data Processing
29
SELECT STATE, STORE_ID, DATE_ID, SUM(AMOUNT), COUNT(DISTINCT CART_ID)
FROM TRANS_DATA
GROUP BY STATE, STORE_ID, DATE_ID
Trade-Offs
30
Trade-Offs
In-Memory PQ
Does not work with smart scans (no direct path reads)
Segment-level checkpoints
Can introduce significant overhead
OLTP activity
Often does not mix well with smart scans
In-memory database option
Not in offloading territory
31