Top Banner
13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance
29

13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

Mar 30, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13Copyright © 2005, Oracle. All rights reserved.

Monitoring and Improving Performance

Page 2: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13-2 Copyright © 2005, Oracle. All rights reserved.

Objectives

After completing this lesson, you should be able to do the following:

• Troubleshoot invalid and unusable objects

• Gather optimizer statistics

• View performance metrics

• Deal with performance issues

Page 3: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13-3 Copyright © 2005, Oracle. All rights reserved.

Performance Monitoring

Memory allocation

issues

Memory allocation

issues

Input/outputdevice

contention

Input/outputdevice

contention

Application code

problems

Application code

problems

Resourcecontention

Resourcecontention

Network bottlenecks

Network bottlenecks

?DBA

Page 4: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13-4 Copyright © 2005, Oracle. All rights reserved.

Monitoring Methodologies

• Reactive

• Proactive:– Server-generated alerts– Automatic Database Diagnostic Monitor (ADDM)

Page 5: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13-5 Copyright © 2005, Oracle. All rights reserved.

Database and Instance Metrics

Several performance statistics are available through:

• Data dictionary

• Dynamic performance views

• Optimizer statistics

DBA

Page 6: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13-7 Copyright © 2005, Oracle. All rights reserved.

Data Dictionary Metrics

You can view the status of:

• PL/SQL code objects

• Indexes

Page 7: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13-8 Copyright © 2005, Oracle. All rights reserved.

Invalid and Unusable Objects

• PL/SQL code objects are recompiled.

• Indexes are rebuilt.

Page 8: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13-10 Copyright © 2005, Oracle. All rights reserved.

Optimizer Statistics

Optimizer statistics are:

• Not real time

• Persistent across instance restarts

• Collected automatically

SQL> SELECT COUNT(*) FROM hr.employees;

COUNT(*)

----------

214

SQL> SELECT num_rows FROM dba_tables

2 WHERE owner='HR' AND table_name = 'EMPLOYEES';

NUM_ROWS

----------

107

Page 9: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13-12 Copyright © 2005, Oracle. All rights reserved.

Using the Manage Optimizer Statistics Page

Page 10: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13-14 Copyright © 2005, Oracle. All rights reserved.

Manually Gathering Optimizer Statistics

Page 11: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13-15 Copyright © 2005, Oracle. All rights reserved.

Dynamic Performance Views

Dynamic Performance views are:

• Real time

• Nonpersistent across instance restarts

SQL> SELECT name, value FROM v$sysstat

2 WHERE name='sorts (memory)' ORDER BY name;

NAME VALUE

--------------- ----------

sorts (memory) 1979183

SQL> /

NAME VALUE

--------------- ----------

sorts (memory) 1979184

Page 12: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13-16 Copyright © 2005, Oracle. All rights reserved.

Viewing Metric Information

1. Use the All Metrics link in the Related Links region.

2. Drill down for in-depth analysis.

Page 13: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13-17 Copyright © 2005, Oracle. All rights reserved.

Reacting to Performance Issues

Use Enterprise Manager to:

• Find key performance issues

• Drill down to the root cause

Page 14: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13-18 Copyright © 2005, Oracle. All rights reserved.

Reacting to Performance Issues

Drill down to performance measurements to identify bottlenecks.

• CPU user: A specific update statement

Page 15: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13-19 Copyright © 2005, Oracle. All rights reserved.

Tuning Tips

Considerations:

• There are some general guidelines that serve as a starting point in performance tuning.

• Your situation may not fit the guideline.

• Test any changes under a representative production environment to see the effects.

• There are written volumes and multiday classes dedicated to tuning an Oracle database.

Page 16: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13-20 Copyright © 2005, Oracle. All rights reserved.

Tuning Activities

The three activities in performance management are:

• Performance planning

• Instance tuning

• SQL tuning

Page 17: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13-21 Copyright © 2005, Oracle. All rights reserved.

Performance Planning

• Investment options

• System architecture

• Scalability

• Application design principles

• Workload testing, modeling, and implementation

• Deploying new applications

Page 18: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13-23 Copyright © 2005, Oracle. All rights reserved.

Instance Tuning

• Have well-defined goals.

• Allocate memory to database structures.

• Consider I/O requirements in each part of the database.

• Tune the operating system for optimal performance of the database.

Page 19: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13-24 Copyright © 2005, Oracle. All rights reserved.

Tuning Memory Allocation

Java pool

Databasebuffer cache

Redo log buffer

Shared pool

Large pool

SGA

Fixed SGA

Streams pool

What is the optimal allocation?

SGA_TARGET = 8G

STATISTICS_LEVEL = TYPICAL

Page 20: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13-26 Copyright © 2005, Oracle. All rights reserved.

Memory Tuning: Guidelines

• Try to fit the SGA into physical memory.

• Tune for a high buffer cache hit ratio, with the following caveats:– Even valid and necessary full table scans lower it.– It is possible that unnecessary repeated reads of

the same blocks are artificially raising it.

• Use the Memory Advisor.

Page 21: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13-28 Copyright © 2005, Oracle. All rights reserved.

Memory Tuning Guidelinesfor the Library Cache

• Establish formatting conventions for developers so that SQL statements match in the cache.

• Use bind variables.

• Eliminate unnecessary duplicate SQL.

• Consider using CURSOR_SHARING.

• Use PL/SQL when possible.

• Cache sequence numbers.

• Pin objects in the library cache.

Page 22: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13-30 Copyright © 2005, Oracle. All rights reserved.

Tuning I/O

• Look for hot spots on the disk.

• Ensure that you have right-sized redo log files.

• Consider moving redo logs to separate disks.

• Consider moving archive logs to separate disks.

• Look for a high I/O rate on the TEMP tablespace.

• Reduce contention for high I/O data files by segregating them.

• Consider striping all data across all disks.

• Consider using Automatic Storage Management.

Page 23: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13-32 Copyright © 2005, Oracle. All rights reserved.

Tuning SQL

• Using the SQL Tuning Advisor

• Using indexes and clusters

• Using optimizer hints

• Using V$SQL_PLAN and EXPLAIN PLAN

Page 24: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13-34 Copyright © 2005, Oracle. All rights reserved.

Tuning Recommendations

Page 25: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13-35 Copyright © 2005, Oracle. All rights reserved.

Recommendation Plan

Page 26: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13-36 Copyright © 2005, Oracle. All rights reserved.

SQL Statistics

select count(*) from x where object_id < 340

select count(*) from x where object_id < 220

Each statement causes a hard parse.

Page 27: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13-37 Copyright © 2005, Oracle. All rights reserved.

Identifying Duplicate SQL

Bind variable candidates

Page 28: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13-38 Copyright © 2005, Oracle. All rights reserved.

Summary

In this lesson, you should have learned how to:

• Troubleshoot invalid and unusable objects

• Gather optimizer statistics

• View performance metrics

• Deal with performance issues

• Describe some basic tuning steps

Page 29: 13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.

13-39 Copyright © 2005, Oracle. All rights reserved.

Practice Overview:Monitoring and Improving Performance

This practice covers the following topics:

• Detecting and repairing unusable indexes

• Using EXPLAIN PLAN• Gathering statistics

• Using the Performance page in Enterprise Manager