Professional Documents
Culture Documents
Oracle.12c SQL Tune Cookbook
Oracle.12c SQL Tune Cookbook
The following is intended to outline our general product direction. It is intended for
information purposes only, and may not be incorporated into any contract. It is not a
commitment to deliver any material, code, or functionality, and should not be relied
upon in making purchasing decisions. The development, release, and timing of any
features or functionality described for Oracles products remains at the sole discretion
of Oracle.
This document in any form, software or printed matter, contains proprietary information
that is the exclusive property of Oracle. Your access to and use of this confidential
material is subject to the terms and conditions of your Oracle Software License and
Service Agreement, which has been executed and with which you agree to comply.
This document and information contained herein may not be disclosed, copied,
reproduced or distributed to anyone outside Oracle without prior written consent of
Oracle. This document is not part of your license agreement nor can it be
incorporated into any contractual agreement with Oracle or its subsidiaries or affiliates.
3 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
Program Agenda
Optimizer
Application
6 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
Why SQL statements regress?
Optimizer-related
Stale/Missing statistics
7 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
Why SQL statements regress?
Application-related
Bad execution plans
- Full table scans
Missing access structures - Cartesian join
Literal usage
8 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
Why SQL statements regress?
Resource and Contention Issues-related
Data fragmentation
Example:-
Logical Contention
enq: TX - allocate ITL entry
- Row lock contention enq: TX - contention
- Block update contention enq: TX - index contention
enq: US - contention
9 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
Sub-optimal SQL performance: Symptoms
Symptoms
Consumes high CPU, buffer gets, I/O, PGA memory
Long running SQL or significantly different
runtimes
High I/O, CPU, memory, network waits
TX Enqueue Waits, Row Lock Contention
Plan regression
SQL appear in
- Top Activity Page
- ASH Analytics Page
- ADDM Report, AWR Report, ASH reports
10 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
Program Agenda
12 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
Identify expensive SQL (Excessive DB time):
ADDM and ASH Analytics
13 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
Identify expensive SQL: ADDM
SQL consuming too much DB time
ADDM
Throughput centric: Goal is to
reduce DB time
Identifies top SQL
Frequency of occurrence
14 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
Identify expensive SQL: ASH Analytics
Flexible Time Picker
15| Copyright 2011, Oracle and/or its affiliates. All rights reserved. |
ASH Analytics
Active Reports Demo
16 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
Identify expensive SQL: ASH Analytics
Active Reports Demo Click on Save
17 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
Identify long running SQL:
Real-Time SQL Monitoring
Automatically
Enabled out-
monitors Shows global
of-the-box with Obviates need
instances of PL/SQL and Guides tuning
no to trace
long running SQL level efforts
performance individual SQL
SQL, PL/SQL statistics
overhead
executions
18 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
Identify long running Database operations:
Real-Time Database Operations Monitoring New in
Database monitoring of
application jobs
Grouping of SQLs, sessions
for the application jobs
Key scenarios: ETL
operations, Quarter End Close
jobs
Driven by application
specified tagging
Oracle Data Pump jobs
automatically monitored
Tagging ability in PL/SQL,
OCI, JDBC
Visibility into top sql statements
19 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
Identify SQL plan changes: SPA
SPA
Tests and predicts impact of system changes
on SQL query performance
Multitenant database-aware
All SQLs are tuned across all PDBs where it has executed before.
New in
Empowers the CDBA to tune across PDBs in one click
22 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
Tuning SQL: SQL Tuning Advisor
SQL Profiling
23 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
Tuning SQL: SQL Plan Baselines
Materialized
Fast refreshable
views and Full refreshable MVs
view logs
Range, Interval, Hash, Range-
Partition Hash, Range-List type, List
table New partitioning schemes on
already partitioned tables
26 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
Tuning SQL: Real-time SQL Monitoring
Insert executed with parallel hint
Tuning SQL: Real-time SQL Monitoring
Parallel Tab
Test Production
Test System: Safe But Database Database Production System: Easier but
32 Copyright 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template
SPA Quick Check
New in EM 12c Database Plug-in 12.1.0.5
Supports routine Optimizer Gather Statistics
production Init.ora parameter changes SPA Quick Check
change use Index creation
Support for DB Release 11g and above Per SQL Time Limits,
cases Resource Consumer
Group
Controlled
Optimal Trial Optimized
Simplifies precise Uses pre-selected STS that represents Mode
Production
Pre-selected Database
Designed and Optimal Trial or Explain Plan Mode STS and
Per SQL Time Limit, Resource Consumer default SPA
optimized for Group
settings
Minimizes use of
Identifies subset SQL Test-executes only production resources
workload with plan SQLs with plan dramatically
changes first changes In general, resource
consumption reduced in the
range of 10x or more
SPA Quick Check: Setup
Minimal use of production resources
38 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
SPA Quick Check
Gather Optimizer Statistics SPA Report
SPA Report
without any
regression
Preventing SQL problems: SPA Quick Check
Init.ora changes: Validate optimizer related init parameter change
Provides actionable
First trial with Create index in Second trial with Generates
recommendations on
current environment invisible mode index invisible comparison report the report (buttons)
Note: Indexes are only visible in a scoped manner to the session, uses optimizer_use_invisible_indexes=true in private session
Program Agenda
Baki ahin
Database Operation
Supervisor
AVEA
Avea is the youngest GSM operator of Turkey with its 13.6 million customers.
3. Results
52 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
Project Overview
Customer Information
- S. Corporation: Manufacturing company in Korea.
53
Solution for Upgrade
Oracle Real Application Testing
Factor Description
PoC for more than 2 months to validate the real effectiveness of RAT and
to assess potential upgrade risks, which cant be found without RAT.
How
Sort sequence changing target program test through module source check.
Performance test & tuning for individual SQL through RAT SPA. (10g vs. 11g )
54
Results
Factor Content
Improved performance through the Optimizer enhancement
Database
:About 15~20% improvement
Performance
RAC efficiency, CPU usage monitoring improvement
Improvement
through the EM function improvements : About 20% improvement
55
Database Manageability
Recommended Sessions
Session General Session Day Time Location
GEN8792 General Session: Database Management Innovations - Oracle Database 12c Manageability Highlights Wednesday 10:15 AM Moscone South 103
CON9582 Oracle Exadata Management Deep Dive with Oracle Enterprise Manager 12c Monday 12:15 PM Westin - Metropolitan I
CON9573 Managing the Oracle Identity Management Platform with Oracle Enterprise Manager Monday 1:45 PM Moscone South - 130
CON9578 Automatic Workload Repository Soup to Nuts: Fundamentals of Database Performance Analysis Monday 3:15 PM Moscone South 104
CON8788 Maximizing Database Performance with Database Replay Tuesday 10:30 AM Moscone South - 308
CON9583 Harness the Power of Oracle Database 12c with Oracle Enterprise Manager Database as a Service Tuesday 3:45 PM Moscone South 305
CON9579 Step-by-Step Cookbook for Identifying and Tuning SQL Problems Wednesday 1:15 PM Moscone South 103
CON4666 Oracle Enterprise Manager 12c Database Lifecycle Management Automatic Provisioning and Patching Wednesday 3:30 PM Moscone South 131
CON8768 DBA Best Practices for Protecting Data Privacy with Oracles Data Masking Wednesday 3:30 PM Moscone West 2024
CON9577 Active Session History Deep Dive: Advanced Performance Analysis Tips Wednesday 3:30 PM Moscone South 104
CON3255 Being Sure: Confident Consolidations with Oracle Real Application Testing 12c Wednesday 5:00 PM Moscone South 306
CON3103 Real Oracle Real Application Testing: What to Expect and Prepare For Thursday 12:30 PM Moscone South - 104
56 Copyright 2013, Oracle and/or its affiliates. All rights reserved.
57 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12