Performance Secret
Performance Secret
Performance
Parallel Processing
Automated Degree of Parallelism
How it works
Statement
executes in parallel
Statement
executes serially
Parallel Statement Queuing
How it works
64 32
64 16
32 128
16
FIFO Queue
8
128
In-Memory Parallel Execution
How it works
SQL Determine the size of the Table is a good candidate Fragments of Table are
statement table being looked at for In-Memory Parallel read into each node‟s
Execution buffer cache
Table is
Table is extremely small extremely Large
• DBA can still invoke the advisor manually for reactive tuning
First execution:
data is read from
disk
PL/SQL Results Cache in Pictures – RAC
Cache Synchronization
between instances can
provide major
performance benefits
Performance
Advisors
Diagnostics and Tuning Advisors
• Since 10.1
– SQL Access Advisor:
• Indexes
• Materialized Views
• Indexes on Materialized Views
• Requires a workload
– SQL Tuning Advisor
• Optimizer in Tuning Mode
• Create profiles for the statements
• Can operate on a single SQL statement
SQL Tuning
• Partition Advisor
– SQL Access Advisor will now recommend partitioning
schemes
• SQL Repair Advisor
– Diagnose and fix bad SQL
SQL Access Advisor: Partitioning
SQL Access Advisor: Recommendations
SQL Repair Advisor
SQL Repair Advisor
DBMS_STATS.SET_TABLE_PREFS
DBMS_STATS.SET_SCHEMA_PREFS
manually:
SQL> exec DBMS_STATS.GATHER_SCHEMA_STATS('SCOTT');
27%
54%
Priority
54%
27%
Statistics: EMPTY
Statistics: STALE
Statistics: OK low
16 GB 120 GB
SGA Memory Flash Cache
• db_flash_cache_size=<size>
• Specifies the amount of flash disk to use
360 GB
Magnetic Disks
Flash Cache
How it works
Extended Buffer Cache
Hot Data
16 GB 120 GB
SGA Memory Flash Cache
Cold Data
360 GB
Magnetic Disks
Flash Cache
How it works
Extended Buffer Cache
Cold Data
360 GB
Magnetic Disks
* Headers for Flash
Cached blocks kept in
SGA
Flash Cache
4. User Process Extended Buffer Cache
reads blocks
from SGA
(copied from
Flash Cache if
not in SGA)
Hot Data Warm Data
16 GB 120 GB
SGA Memory 3. Clean blocks Flash Cache
moved to
Flash Cache
based on
LRU*
Cold Data
360 GB
Magnetic Disks
* Headers for Flash
Cached blocks kept in
SGA
Performance
Plan Management
Something Has Changed…
HJ
• Better consolidation
– Extreme consolidation of servers & storage
– Load balancing to protect service levels
• Enhanced virtualization
– Extends and improves database availability and
flexibility when running in a virtual server
Opportunity:
• Eliminate database outages for operating
system upgrades/patching and database
patching
• Replace or migrate servers and storage
without downtime
• Reduce OP-EX via online maintenance – no
overtime pay, etc.
• Reduce cost and complexity of cluster
failover solutions by using single stack
Key Capabilities:
Value Proposition: • Fast storage failover
• Better availability than you get with 3rd-party • Rolling
cluster failover upgrades/patches
(online database
• Better availability than you get with a stand- relocation)
alone EE database
• Online storage add and
remove
RAC One Node
The “Always On” Single Instance Database
Office
Front
Back
– Consolidation
– Live Migration
– Rolling Patches
Free
DW – Server failover
– Standardized DB environment
RAC One
• Online upgradeable to full RAC
VM Consolidation
Value Proposition:
• Improved flexibility, manageability, and
availability of servers and storage at lower Key Capabilities:
cost as compared with siloed databases
• Fewer servers, storage arrays, and operating • Instance Caging
systems to manage compared to VM • Online Load balancing
consolidation (online database
relocation)
• Storage Pooling
Use Case #2: Better Consolidation
Server Consolidation
Before Consolidation After Consolidation
5 servers 1 server
DB-A DB-B DB-C DB-D DB-E DB-A DB-B DB-C DB-D DB-E
DB-A DB-B DB-C DB-D DB-E DB-A DB-B DB-C DB-D DB-E
DB-A DB-B DB-C DB-D DB-E DB-A DB-B DB-C DB-D DB-E
Full Full 85% 85% 75% 20% Free – but fewer disks!
free free free
Manageability
Manageability
SQL Real time monitoring
SQL Real-Time Monitoring
• Dedicated statistics collected for a single execution of a
SQL statement when its execution becomes high-load
– Target:
• Parallel queries, parallel DML or parallel DDL
• Execution that exceeds 5 sec of CPU or I/O time
– Global SQL level statistics are collected: V$SQL_MONITOR
– Plan level statistics are collected (#rows, memory, temp space,
start/end date): V$SQL_PLAN_MONITOR
– Statistics are updated quasi real-time while the query executes
– Statistics for completed executions are retained for at least 5 minutes
– Feature switched on by default
• Part of Tuning Pack
• Note:1229904.1: Real-Time SQL Monitoring in 11g
Up To
4X
Compression
Compression
Free Space
uncompressed
compressed
Data Storage
2500
2000
1500
Table Scans
1000 0.4
500
0.3
DML Performance
0
0.2 40
3x Saving 30
0.1
20
0
10
2.5x Faster
0
< 3% Overhead
Running
Processes
• 4 CPU server
• Workload is a mix of OLTP transactions, parallel queries, and
DMLs from Oracle Financials
– Database A:
• Reporting: 60% of I/O resources
• ETL: 40% of I/O resources
– Database B:
• Interactive: 30% of I/O resources
• Batch: 70% of I/O resources
I/O
Resource
Manager
Report Report Report Report
Allocation: 30%
Allocation: 60% Allocation: 10%
Exadata
Storage
Allocation: 30%
Allocation: 60% Actual: 75% Allocation: 10%
Actual: 0% Actual: 25%
Exadata
Storage
Allocation: 30%
Allocation: 60% Actual: 80% Allocation: 10%
Actual: 0% Limit: 20%
Actual: 20%
Exadata
Storage
Resource plan can specify hard utilization limits per database (new in 11.2.0.2!)
Useful for hosted environments and providing consistent performance
I/O Utilization Limit Results
100%
90%
80%
70%
60% No I/O Limit
Disk 50% 75% I/O Limit
Utilization
40% 50% I/O Limit
30% 25% I/O Limit
20%
10%
0%
Time
40%
What if you cannot tolerate
performance degradations for
certain workloads?
OLTP Reports OLTP +
only only Reports
Managing Contending Workloads
100%
20%
CPU
With Resource Manager,
80% 90% 80% 90% you control how CPU
Usage
resources should be
allocated
10%
OLTP Reports
only only
OLTP + Reports OLTP + Reports
Resource Manager Enabled
OLTP Reports
Prioritized Prioritized
Configuring Resource Manager
OLTP
service = „Customer_Service‟
module = „AdHoc%‟
Priority 1: OLTP
Reports Priority 2: Reports
30% Priority 3: Low-Priority
OLTP
60%
Low-Priority
10% Hybrid Plan with Hard Limits
• Enable manually
– Set resource_manager_plan parameter
• Enable automatically
– Configure a job scheduler window to use a resource plan
– Weekdays 8 am – 6 pm: DAYTIME_PLAN
– Weeknights and weekends: OFFHOURS_PLAN
Resource Manager User Interface
Oracle-
Internal CPU
Queue OLTP Reports
Resource Plan:
CPU Resource OLTP 75%
Sessions
Manager Reports 25%
scheduled every
100 ms (OLTP picked 3 out of 4 times)
Object_4
Object_3
Object_2
Object_1
Pre-upgrade
edition
Editions & object visibility
User created.
Grant succeeded.
Edition created.
Online Application Upgrade
Edition-based redefinition
User altered.
Grant succeeded.
Online Application Upgrade
Edition-based redefinition
SYS_CONTEXT('USERENV','CURRENT_EDITION_NAME')
--------------------------------------------------
VERSION2
SYS_CONTEXT('USERENV','CURRENT_EDITION_NAME')
----------------------------------------------
ORA$BASE
Session altered.
SYS_CONTEXT('USERENV','CURRENT_EDITION_NAME')
-----------------------------------------------
VERSION2
• OPTIMIZER_USE_INVISIBLE_INDEXES
• Default: FALSE
• Values: TRUE
FALSE
• Purpose: "Invisible" indexes will be ignored by the optimizer if set to
FALSE. But DMLs will be still executed to the index.
• Motivation: Isolated testing of performance effects of an
index based on a session level
• Example:
CREATE INDEX emp_ename ON emp(ename)
INVISIBLE;
ALTER SESSION SET
OPTIMIZER_USE_INVISIBLE_INDEXES=TRUE;
• OPTIMIZER_USE_PENDING_STATISTICS
• Values: TRUE | FALSE
• Purpose: Mitigate risk with new stats post upgrade
• Use case:
• Switch on pending stats temporarily:
DBMS_STATS.SET_GLOBAL_PREFS('PENDING','TRUE');
• Gather new Oracle 11g statistics:
DBMS_STATS.GATHER_TABLE_STATS('APPUSER','TAB_1');
• Test your critical SQL statement(s) with pending stats:
ALTER SESSION SET optimizer_use_pending_statistics=TRUE;
• When proven publish the new Oracle 11g statistics:
DBMS_STATS.PUBLISH_PENDING_STATS();
• Goal:
– Record and replay a real workload to see how the new system
performs
– Find regressions and changing plans before the upgrade
File 1
• Independent of client protocol
Oracle
Database
Transport SQLs
– Disadvantages of LONG:
• Maximum number of LONG columns per table : 1
• No replication possible with LONG and LONG RAW
• Attention:
– LONG LOB conversion is irreversible
• Conversion:
ALTER TABLE long_tab MODIFY ( long_col CLOB );
• API access:
PL/SQL (DBMS_LOB), JDBC, .NET, PHP, ...
• Reference:
Wellcome Sanger Trust Institute - ~500TB Database
http://www.oracle.com/us/corporate/customers/wellcome-trust-
sanger-1-db-cs-322784.pdf?ssSourceSiteId=otnen
Directory created.
Directory created.
EXECUTE and PREPROCESSOR
SQL> CREATE TABLE EMP_ET
2 (
3 "EMPNO" NUMBER(4),
4 "ENAME" VARCHAR2(10),
5 "JOB" VARCHAR2(9),
6 "MGR" NUMBER(4),
7 "HIREDATE" DATE,
8 "SAL" NUMBER(7,2),
9 "COMM" NUMBER(7,2),
10 "DEPTNO" NUMBER(2)
11 )
12 ORGANIZATION EXTERNAL
13 ( TYPE oracle_loader
14 DEFAULT DIRECTORY load_dir
15 ACCESS PARAMETERS
16 ( RECORDS DELIMITED BY NEWLINE
17 PREPROCESSOR exec_dir:'run_gunzip.sh'
18 FIELDS TERMINATED BY "|" LDRTRIM
19 )
20 location ( 'emp.dat.gz')
21 )
22 /
Table created.
EXECUTE and PREPROCESSOR
/usr/bin/gunzip -c $*
EMPNO ENAME
---------- ----------
7369 SMITH
7499 ALLEN
7521 WARD
7566 JONES
7654 MARTIN
Extending ASM to Manage ALL Data