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

Post on 30-Mar-2015

217 Views

Category:

Documents

2 Downloads

Preview:

Click to see full reader

Transcript

13Copyright © 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

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

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

Monitoring Methodologies

• Reactive

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

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

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

Data Dictionary Metrics

You can view the status of:

• PL/SQL code objects

• Indexes

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

Invalid and Unusable Objects

• PL/SQL code objects are recompiled.

• Indexes are rebuilt.

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

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

Using the Manage Optimizer Statistics Page

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

Manually Gathering Optimizer Statistics

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

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.

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

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

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.

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

Tuning Activities

The three activities in performance management are:

• Performance planning

• Instance tuning

• SQL tuning

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

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.

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

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.

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.

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.

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

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

Tuning Recommendations

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

Recommendation Plan

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.

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

Identifying Duplicate SQL

Bind variable candidates

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

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

top related