Professional Documents
Culture Documents
SANGAM17 Top Tips Database Performance FINAL
SANGAM17 Top Tips Database Performance FINAL
Database Performance
GP (Gongloor Prabhaker)
Senior Director of Product Management
Oracle Management Cloud, Oracle Corporation
SANGAM17
Dec 9, 2017
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 1
Safe Harbor Statement
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 Oracle’s products remains at the sole discretion of Oracle.
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 2
Program Agenda
1 Introduction
2 Oracle Database Performance Tuning Fundamentals
3 Performance Tuning Tips
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 3
Program Agenda
1 Introduction
2 Oracle Database Performance Tuning Fundamentals
3 Performance Tuning Tips
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 4
Top Challenges: Database Management
45%
?
Identifying application (SQL)
issues
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 6
Environment Changes That Affect Performance
• Data growth
• User population growth
• Infrastructure changes
– Server upgrades
– Changes in size or type of disk storage
– Migration to new platforms including migration to
Cloud
• Database Consolidation
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal 7
DBA Actions That Affect Performance
• Adding or dropping indexes, partitioning tables,
adding materialized views
• Gathering optimizer statistics
• Modifying init.ora parameters
• Implementing new features such as Compression,
Database In-Memory
• Applying patches – one offs, patch bundles
• Version upgrades or patchsets
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal 8
Program Agenda
1 Introduction
2 Oracle Database Performance Tuning Fundamentals
3 Performance Tuning Tips
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 9
DB Time
• Total time in database calls by foreground DB Time
sessions
• Includes
– CPU time Wait
– IO time
– Active wait (non-idle wait) time I/O
• Basic unit for Oracle performance analysis
CPU
• Active waits component broken into wait
categories (Application, CPU, IO…)
• Average Active Sessions = Total DB Time/Elapsed
Time
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 10
Quiz
True or False:
The maximum DB Time a four CPU system can accumulate in one hour
is four hours of DB Time.
Answer: FALSE
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 11
Colored Areas in EM = DB Time
• Active Sessions by wait class over time, total area under curve is DB Time
• DB Time distribution should be considered when tuning
• More DB time, more tuning opportunities
• DB time increases as system load increases or system performance degrades
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 13
DB Time in AWR Report
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 14
Program Agenda
1 Introduction
2 Oracle Database Performance Tuning Fundamentals
3 Performance Tuning Tips
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 15
Tips on Reading an AWR Report
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 16
Tips On Reading An AWR Report
• Tip:
– Check operating system level first – verify not maxed out on CPU
– DB Time is inflated when CPU bound
Quiz: Which regions / page has above information for maxed out CPU?
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 17
Tips On Reading An AWR Report
• For a basic understanding of the database and environment – check the top
of the report:
– DB Time vs elapsed time
– Number of CPUs and cores
– Amount of memory
– Number of database sessions
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 18
Tips On Reading An AWR Report
• Read the ADDM findings at the top of the report – ADDM report
automatically included starting with database 12
• Look at the full ADDM report at the end of the AWR report
• Identifies top DB Time targets for tuning
• Tip: ADDM specifies subsystems that are not a problem, e.g. network, interconnect
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 19
Tips On Reading An AWR Report
• Look at 10 top timed events section, focus on highest DB Time that can be
reduced with least effort
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 20
Tips On Reading An AWR Report
• Review top SQL sections based on top 10 events. Identify top SQL
candidates for tuning:
– If CPU is a top event, look at top SQL by CPU section
– If I/O is a top event, look at top SQL by I/O section
– If wait events are top events, look at SQL by elapsed time section
– Frequently the same SQL will show up in one or more of these sections
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 21
Tips On Reading An AWR Report
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 22
Database Performance Hub
Holistic Performance Management
• @?/rdbms/admin/perfh
ubrpt.sql
– Prompted for type of
report (typical, basic, all,
…), DB ID, Instance
number, etc.
– Time range (not snapshots)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 25
Demo
Perfhub Report
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 26
Tips on Assuring Performance During
Routine System Changes
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 27
Proactive Performance Management: SPA Quick Check
• Helps users predict the impact of routine
system changes on production SQL
workload SQL Plans + Statistics SQL Plans + Statistics
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 28
Proactive Performance Management
Predict the impact of routine system changes on SQL workload response time
• Optimized
– Optimized for use on prod systems SPA Quick Check
– Optimal Trial or Explain Plan mode
– Disable multi-executions, full DML execute disabled
Per SQL Time Limits,
Optimal Trial
• Controlled
Limits testing scope to
Mode, no DML Controlled/Sc
private session
execute Optimized oped
• Change-Aware Production
Database
Pre-selected
– Context-aware change testing workflows, such as, STS and
default SPA
– Optimizer gather statistics settings
DBA
– Init.ora parameter changes
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 29
Proactive Performance Management
Predict the impact of system changes on SQL workload response time
3
2
5
1
4
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 30
Demo
SQL Performance Analyzer
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 31
New in
SPA - Concurrent SQL Execution 18.1
• SPA trials are currently executed serially one statement at a time
– This can lead to long tests when SQL Tuning Sets contain a large number of
statements. For example, EBS suite may have 1 million unique SQL statements
• Concurrent SQL execution within a SPA trial reduces duration to complete
the trial, therefore reduces testing time
– User specifies degree of parallelism with SPA parameter TEST_EXECUTE_DOP
– For example, a SQL Tuning Set with 125,000 statements reduced testing from
12.5 hours to 2 hours with a degree of parallelism of 8
• Tip: Use SPA concurrent SQL execution in test environment for STS with a
large number (thousands or higher) of SQL statements
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 32
New in
SPA – Result Set Validation 18.1
• Result set validation required for certain environments – e.g. government
drug research trials, pharma industries, etc. An additional assurance SQL
produces correct results with new environment / software
• SPA report can be generated for before and after change trials comparing
whether identical result sets were produced
• SPA result set validation uses generated hash key to compare result sets in
two trials
– Enabled with SPA parameter COMPARE_RESULTSET
• Tip: Run before and after trials with exact same dataset for result set
validation
• If result sets differ with same input dataset – contact Oracle Support
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 33
Tips on SQL Tuning and Exadata
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 34
Reactive Performance Management
How to go about tuning the sub-optimal SQL?
Gather Missing or Stale Statistics
Create a SQL Profile
Statistics Analysis Add Missing Access Structures
SQL Profiling Modify SQL Constructs
Access Path Analysis Adopt Alternative
SQL Restructure Analysis Execution Plan
• SQL Tuning Advisor provides DB Time improvement benefits for its recommendations
• Choose the highest DB Time, most targeted recommendation
• SQL Profile affects single statement
• Index could affect entire workload – requires additional validation (SQL Access Advisor)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 36
NEW IN
SQL Tuning Advisor Exadata Enhancement 18.1
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 38
Tips on Tuning Multitenant Databases
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 39
AWR and Multitenant: Pre-DB 11.2 Architecture and
Limitations
• Single AWR repository per database AWR Architecture (pre-DB12.2)
– For non-CDB resides in SYSAUX
Internal Clients
– For CDB resides in Root’s SYSAUX (12.1)
Self Tuning
ADDM
• AWR does not have notion of AWR
Components
Repository (AWR)
SGA
– Missing Time-Wait model, sysmetrics statistics Background
Processes
DBA_HIST Views V$ Views
per PDB
– No break down per PDB level at root
OEM SQL*Plus
• AWR data not transportable along
External Clients
with PDB
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal 40
Solution: New AWR Architecture for Multitenant (DB 12.2)
Per-PDB AWR Support
AWR AWR
AWR
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 42
Tips on Tuning Active Data Guard
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 43
AWR Support for Remote Snapshots and ADG
• Problem
– AWR snapshots cannot be taken in a read-only standby environment
– Performance monitoring and analysis is limited to basic STATSPACK functionality
• Solution
– In Oracle Database 12.2, AWR framework enhanced to support capture of remote
snapshots from any generic database including Active Data Guard (ADG) databases
• A target catalog database collects snapshots from the remote databases (sources)
• Snapshots can be collected automatically or manually
• AWR tables on the catalog database accumulate snapshot data from all sources via database links
• Source databases must be registered on the catalog via new
DBMS_WORKLOAD_REPOSITORY.REGISTER_REMOTE_DATABASE API
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 44
Remote Snapshot Configuration for ADG Database
ADG Reader Farm
Source databases
Remote AWR Data
4. Define the target database
Catalog database
5. Create the topology
6. Register the source databases
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 45
SQL Tuning Advisor Support for Active Data Guard
• Problem
– ADG databases are widely used to offload reporting or ad hoc query-only jobs from
primary
– Reporting workload profile is different from primary and often requires tuning
• Solution
• Oracle Database 12.2 introduces the ability to tune SQLs workloads running on ADG database
• All SQL Tuning Advisor tasks issued at the standby
– Create tuning task, execute tuning task and implement SQL Profile recommendations can be run on standby
– Test execution (heavy lifting) happens on standby, only minimal write related activity on primary
• The required data for the above tasks are fetched from primary over a database link from standby
• Task details and tuning results are stored at primary and the essential data required to construct the
report is accessed remotely from primary
• The report is constructed locally at the standby, with no CPU overhead in primary
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 46
SQL Tuning Advisor Support for Active Data Guard
Primary Standby
create tuning task
execute tuning task
report tuning task
dblink_to_primary implement recommendations
– All changes are done on primary and propagated from primary to standby by redo apply
– Support for PDB level tuning
– The tuning task is executed at the standby, with no CPU overhead in primary
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 48
Reactive Performance Management
Diagnose persistent performance issues
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 49
Reactive Performance Management
• My database is unresponsive and
end-users are complaining of
performance issues. Should I
bounce the database or wait for
some time for problem to go away?
• Database Hung state
- Blocking Sessions
- Memory allocation issues
- Library cache issues
- Unresponsive Storage (ASM)
- Interconnect problems
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 50
Reactive Performance Management
Tip: Diagnose hung database issues using Real-Time ADDM
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 51
Reactive Performance Management
Tip: Diagnose Hung database issues using Real-Time ADDM
• Refer back to Real-Time ADDM to nail this down as login storm issue, understand more about this query
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 52
Summary
• To improve database performance, reduce DB Time
• Use automated tools such as SQL Performance Analyzer and SQL Tuning
Advisor to maximize productivity
• Use Real-Time ADDM to troubleshoot hung databases
• Use AWR and Perfhub for in-depth performance analysis
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 55
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 56