Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Top Tips for Improving Database Performance
Kurt EngeleiterPrincipal Product ManagerOracle
Venkata Ravi Kumar YenugulaLead Oracle DBARaymond James
Confidential – Oracle Internal/Restricted/Highly Restricted
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
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.
Confidential – Oracle Internal/Restricted/Highly Restricted 2
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
Introduction
Oracle Database Performance Tuning Fundamentals
Performance Tuning Tips
1
2
3
Oracle Confidential – Internal/Restricted/Highly Restricted 3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
Introduction
Oracle Database Performance Tuning Fundamentals
Performance Tuning Tips
1
2
3
Oracle Confidential – Internal/Restricted/Highly Restricted 4
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Top Challenges: Database Management
52% Rapid diagnoses of database
performance problems
45% Identifying application (SQL)
issues
37% Validating and applying SQL
tuning solutions
Key Takeaway: Improve & Ensure Higher Quality of Service
?
Source: THE RAPIDLY ACCELERATING CLOUD-ENABLED ENTERPRISE: 2015 IOUG Survey On Database Manageability
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
What can cause database performance to change?
Oracle Confidential – Internal/Restricted/Highly Restricted 6
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
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
7Oracle Confidential – Internal
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
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
8Oracle Confidential – Internal
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
Introduction
Oracle Database Performance Tuning Fundamentals
Performance Tuning Tips
1
2
3
Oracle Confidential – Internal/Restricted/Highly Restricted 9
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 10
DB Time
• Total time in database calls by foreground sessions
• Includes
– CPU time
– IO time
– Active wait (non-idle wait) time
• Basic unit for Oracle performance analysis
CPU
I/O
Wait
DB Time
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Quiz
True or False:
The maximum DB Time a four CPU system can accumulate in one hour is four hours of DB Time.
Confidential – Oracle Internal/Restricted/Highly Restricted 11
In addition to using CPU, and doing I/O, one or many database sessions could be in non-idle wait for that one hour. Each of those sessions would be accumulating DB Time. The database could accumulate much more than four hours of DB Time in one hour.
Answer: FALSE
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 13
Colored Areas in EM = DB Time
• Active Sessions by wait class over time
• More DB time, more tuning opportunities
• DB time increases as system load increases
• DB time increases as system performance degrades.
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 14
DB Time in AWR Report
• Top 10 events in AWR report are reported in order of DB Time, descending
• TIP: To improve database performance, focus on:
• Reducing the highest DB Time events which can be done with the least effort
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
Introduction
Oracle Database Performance Tuning Fundamentals
Performance Tuning Tips
1
2
3
Oracle Confidential – Internal/Restricted/Highly Restricted 15
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Tips on Reading an AWR Report
Confidential – Oracle Internal/Restricted/Highly Restricted 16
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
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
Confidential – Oracle Internal/Restricted/Highly Restricted 17
Db file sequential read
Run-queue
On CPU Db file sequential read
Run-queue
On CPU
User 1
Actual wait time Actual wait time
Recorded wait time Recorded wait time
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
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
Confidential – Oracle Internal/Restricted/Highly Restricted 18
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
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
Confidential – Oracle Internal/Restricted/Highly Restricted 19
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
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
Confidential – Oracle Internal/Restricted/Highly Restricted 20
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
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
Confidential – Oracle Internal/Restricted/Highly Restricted 21
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Tips On Reading An AWR Report
• Review the database parameters section
• Tip: Best practice is to have as few non-default database parameters set as possible
–Minimizing non-default parameters means will execute most common code path –most optimized, fewest potential issues
– Underscore parameters particularly suspect
Confidential – Oracle Internal/Restricted/Highly Restricted 22
x
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Database Performance Hub
23
Holistic Performance Management
• Single view of DB performance
– ADDM, SQL Tuning, Real-Time SQL Monitoring, ASH Analytics
• Switch between ASH analytics, workload view, ADDM findings and SQL monitoring seamlessly
• Supports both real-time & historical mode
• Historical view of SQL Monitoring reports
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Tip: How to Generate Performance Hub Report
• Performance Hub report generated from SQL*Plus:
– @$ORACLE_HOME/rdbms/admin/perfhubrpt.sql
OR calling dbms_perf.report_perfhub(….) function
• Performance Hub appended to AWR report:
– @$ORACLE_HOME/rdbms/admin/awrrpt.sql
– Choose ‘active-html’ report
24
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
DemoPerfhub Report
Oracle Confidential – Internal/Restricted/Highly Restricted 25
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Tips on Assuring Performance During Routine System Changes
Confidential – Oracle Internal/Restricted/Highly Restricted 26
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
• Helps users predict the impact of routine system changes on production SQL workload
• Low overhead capture of SQL workload to SQL Tuning Set (STS)
• Build different SQL trials (experiments) of SQL statements performance by test execution or explain plan
• Day to day use cases integrated with SPA Quick Check, SQL Plan Baselines, & SQL Tuning Advisor to form an end-to-end solution
Oracle Confidential – Internal/Restricted/Highly Restricted 27
Proactive Performance Management: SPA Quick Check
Analysis Report
Compare SQLPerformance
Post-change TrialPre-change Trial
SQL Plans + Statistics SQL Plans + Statistics
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
• Optimized– Optimized for use on prod systems
– Optimal Trial or Explain Plan mode
– Disable multi-executions, full DML execute disabled
• Controlled– Per SQL time limits
– Testing scoped to private session
– Associate with Resource Consumer Group
• Change-Aware– Context-aware change testing workflows, such as,
– Optimizer gather statistics
– Init.ora parameter changes
Oracle Confidential – Internal/Restricted/Highly Restricted 28
Proactive Performance ManagementPredict the impact of routine system changes on SQL workload response time
SPA Quick Check
Production Database
OptimizedControlled/Sc
oped
Change-Aware
Optimal Trial
Mode, no DML
execute
Pre-selected
STS and
default SPA
settings
Per SQL Time Limits,
Limits testing scope to
private session
Context-aware
change testing
DBA
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Proactive Performance Management
Oracle Confidential – Internal/Restricted/Highly Restricted 29
Predict the impact of system changes on SQL workload response time
1
4
2
3
5
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
DemoSQL Performance Analyzer
Oracle Confidential – Internal/Restricted/Highly Restricted 30
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SPA - Concurrent SQL Execution
• 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
Confidential – Oracle Internal/Restricted/Highly Restricted 31
New in
18.1
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SPA – Result Set Validation
• 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 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
Confidential – Oracle Internal/Restricted/Highly Restricted 32
New in
18.1
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Tips on SQL Tuning and Exadata
Confidential – Oracle Internal/Restricted/Highly Restricted 33
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Reactive Performance Management
Oracle Confidential – Internal/Restricted/Highly Restricted 34
How to go about tuning the sub-optimal SQL?
34
Statistics Analysis
SQL Profiling
Access Path Analysis
SQL Restructure Analysis
Alternative Plan Analysis
Parallel Query Analysis
Automatic Tuning Optimizer
Administrator
Comprehensive SQL Tuning Recommendations
Gather Missing or Stale Statistics
Create a SQL Profile
Add Missing Access Structures
Modify SQL Constructs
Adopt Alternative
Execution Plan
Create Parallel SQL Profile
SQL Tuning Advisor
• Gives recommendations on various problems found during analysis phase
• Uses the same CBO but has more time budget for comprehensive analysis
• Identifies alternate execution plans using real time and historical performance data
• Recommends SQL profile to compensate for incorrect statistics and transparently improve performance
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 35
Tip: SQL Tuning Advisor – Choose Highest DB Time, Most Targeted Improvement Recommendation
• 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. |
SQL Tuning Advisor Exadata Enhancement
• SQL Tuning Advisor detects if SQL is executing on Exadata
• SQL Tuning Advisor privately gathers system statistics and does analysis with and without these statistics
• If a better execution plan is found with these system statistics, an Exadata aware SQL Profile will be recommended
• Can result in 10x or better performance improvement for SQLs which can benefit from Exadata hardware - e.g. cell smart scans
Confidential – Oracle Internal/Restricted/Highly Restricted 36
NEW IN
18.1
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SQL Tuning Advisor Exadata Enhancement
Confidential – Oracle Internal/Restricted/Highly Restricted 37
NEW IN
18.1
Without Exadata aware SQL Profile – 1.9 minutes:
With Exadata aware SQL Profile – 13 seconds:
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Tips on Tuning Active Data Guard
Confidential – Oracle Internal/Restricted/Highly Restricted 38
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
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
Oracle Confidential – Internal/Restricted/Highly Restricted 39
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Remote Snapshot Configuration for ADG Database
Oracle Confidential – Internal/Restricted/Highly Restricted 40
Primary
Local AWR Data
Catalog database
Remote AWR Data
ADG Reader Farm
Source databases
Active Data Guard 3. Define the source databases
4. Define the target database
5. Create the topology
6. Register the source databases
7. Register the source databases for AWR service
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
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
Oracle Confidential – Internal/Restricted/Highly Restricted 41
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
SQL Tuning Advisor Support for Active Data Guard
42
Primary Standby
dblink_to_primary
create tuning taskexecute tuning taskreport tuning taskimplement 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. |
Tips on Troubleshooting a Hung Database
Confidential – Oracle Internal/Restricted/Highly Restricted 43
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Reactive Performance Management
Oracle Confidential – Internal/Restricted/Highly Restricted 44
Diagnose persistent performance issues
Real-Time ADDM
ComparePeriod ADDMADDM
Enhanced Real-Time
ADDM
• Diagnose persistent performance issues
• Analyzes AWR snapshots
• Regular interval
• Automatic / Manual
• In-depth performance comparison across two periods
• Relies on AWR data
• Manual
• Hung or extremely slow databases
• Uses a normal and diagnostic mode connection
• Manual
• Proactively detect & diagnose transient high-impact problems
• Built inside the DB
• Automatically runs every 3 seconds
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
• 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
Oracle Confidential – Internal/Restricted/Highly Restricted 45
Reactive Performance Management
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Reactive Performance Management
Oracle Confidential – Internal/Restricted/Highly Restricted 46
Tip: Diagnose hung database issues using Real-Time ADDM
• Identify the problem area
• Turns out to be a SQL that consumes significant amount of DB Time
• Review SQL Monitor report of the problem SQL for in-depth analysis
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Reactive Performance Management
Oracle Confidential – Internal/Restricted/Highly Restricted 47
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. |
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
Oracle Confidential – Internal/Restricted/Highly Restricted 50
RAYMOND JAMES FINANCIAL
HTTPS://WWW.RAYMONDJAMES.COM/
51
AB
OU
T M
E
Oracle Certified Master (OCM)
Oracle ACE Director
Oracle ACE Spotlight for the month – Jun 2016
Oracle Magazine – July/Aug 2017
“Expert” level in Oracle Developer Community
Published 100+ Articles in Oracle Technology Network (OTN)
Oracle Speaker @
Oracle Open World 2017
New York Oracle User Group (NYOUG)
Independent Oracle User Group (IOUG)
APAC Webinar TOUR 2017
Oracle Technology Network (OTN)
Sangam (Largest Oracle Event in India)
All India Oracle User Group (AIOUG)
Author of 100+ Oracle Articles
Oracle Technology Network (OTN)
Toad World - Connected-Driven Innovation
OTech Magazine
All things ORACLE from Redgate
UKOUG Library
RAVI KUMAR YV
Performance Active Hub Report – Oracle Exadata x6 (HR)
Performance Hub active report shows Load Profile, Active Sessions, Host CPU and IO
Performance Active Hub Report – Oracle Exadata x6 (HR)
Performance Hub active report shows CELL CPU, Read/Write Latency and IO Requests
Performance Active Hub Report – Oracle Exadata x6 (HR)
Performance Hub active report shows Instance-wise Resources Utilization
Performance Active Hub Report – Oracle Exadata x6 (HR)
Performance Hub active report enables you CELL Level Statistics (Flash Cache and IO bytes)
SQL Performance Analyzer Task Report – Buffer Gets
Change-aware: Knows what change is being tested.
Intelligently limits impact to private test session.
SQL Performance Analyzer Task Report – Elapsed Time
Helps users predict the impact of system changes on SQL workload.
Low overhead capture of SQL workload to SQL Tuning Set (STS) on production system
SQL Performance Analyzer Task Report – Buffer Gets
After Implementation through SPA – SQL ID ‘74cpnuu24wmx7'
SQL Performance Analyzer Task Report – Elapsed Time
After Implementation through SPA – SQL ID ‘74cpnuu24wmx7'
EXAFUSION PARAMETER
61
Exafusion is Direct-to-Wire protocol allows database processes to read
and send Oracle RAC messages directly over the Infiniband network
bypassing the overhead of entering the OS kernel, and running the
normal networking software stack.
This improves the response time and scalability of the Oracle RAC
environment on Oracle Exadata. Data is transferred directly from user
space to the Infiniband network, leading to reduced CPU utilization
and better scale-out performance.
PRE-REQUISITES FOR EXAFUSION
62
Pre-Requisites for Exafusion
Oracle Exadata Storage Server Software release 12.1.2.1.1 or later.
Oracle Database software Release 12.1.0.2.0 BP11 or later.
Oracle Enterprise Kernel 2 Quarterly Update 5 (UEK2QU5) kernels (2.6.39-400.2nn).
Enable ‘Exafusion’ Parameter
Exafusion is disabled by default.
To enable Exafusion, set the EXAFUSION_ENABLED initialization parameter to 1.
To disable Exafusion, set the EXAFUSION_ENABLED initialization parameter to 0.
This parameter cannot be set dynamically. It must be set before instance startup.
All of the instances in an Oracle RAC cluster must enable this parameter, or all of the instances in
an Oracle RAC cluster must disable the parameter.
Improved Response Time and GC waits, Bottlenecks
63
BEFORE EXAFUSION AFTER EXAFUSION
The expected result is that GC waits have reduced latency due to elimination of the
normal kernel networking overhead.
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 64