0% found this document useful (0 votes)
9 views25 pages

Tuning The PGA

The document is a lecture on Oracle Database Performance Tuning focused on the Program Global Area (PGA). It covers topics such as PGA usage, memory management configurations, diagnosing performance issues, and utilizing V$ views for monitoring. Key objectives include understanding work area sizes, configuring automatic memory management, and analyzing performance statistics.

Uploaded by

KaNika TH11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views25 pages

Tuning The PGA

The document is a lecture on Oracle Database Performance Tuning focused on the Program Global Area (PGA). It covers topics such as PGA usage, memory management configurations, diagnosing performance issues, and utilizing V$ views for monitoring. Key objectives include understanding work area sizes, configuring automatic memory management, and analyzing performance statistics.

Uploaded by

KaNika TH11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Tuning the PGA

By Ahmed Baraka

Oracle© Database Performance Tuning - a course by Ahmed Baraka


Objectives
In this lecture, you should learn how to perform the following:
• Understand PGA usage
• Describe work area size types
• Describe the possible PGA memory management configurations
• Configure the automatic PGA memory management
• Obtain information about PGA from V$ views
• Describe PGA wait events
• Describe PGA activity statistics
• Use V$PGASTAT
• Diagnose PGA Performance Issues
• Access PGA Memory Advisory
• Analyze 'Process Memory Summary' section in AWR reports
Oracle© Database Performance Tuning - a course by Ahmed Baraka
Oracle Program Global Area (PGA)

Instance
SGA
Buffer Shared Pool Java Large Redo Log
Cache Pool Pool Buffer
Library Cache

Data Dict. Cache

PGA
SQL Work Private Session
Area SQL Area Memory

Oracle© Database Performance Tuning - a course by Ahmed Baraka


Oracle Program Global Area (PGA)

SQL Work Area Server


Session Memory Private SQL A. Process

Oracle© Database Performance Tuning - a course by Ahmed Baraka


Oracle Program Global Area (PGA)

sort operations •
hash joins • SQL Work Area Server
bitmap operators • Session Memory Private SQL A. Process

Oracle© Database Performance Tuning - a course by Ahmed Baraka


Oracle Program Global Area (PGA)

SQL Work Area Server


Session Memory Private SQL A. Process

• Information about a parsed SQL statement


• Memory used by PL/SQL such as PL/SQL tables
• Session-specific information

Oracle© Database Performance Tuning - a course by Ahmed Baraka


Oracle Program Global Area (PGA)

SQL Work Area Server


Session Memory Private SQL A. Process

• Session variables

Oracle© Database Performance Tuning - a course by Ahmed Baraka


Oracle Program Global Area (PGA)

SQL Work Area Server


Session Memory Private SQL A. Process

SQL Work Area Server


Process
Session Memory Private SQL A.

SQL Work Area Server


Session Memory Private SQL A. Process

Oracle© Database Performance Tuning - a course by Ahmed Baraka


Oracle Program Global Area (PGA)

Instance PGA

SQL Work Area Server


Session Memory Private SQL A. Process

SQL Work Area Server


Process
Session Memory Private SQL A.

SQL Work Area Server


Session Memory Private SQL A. Process

Oracle© Database Performance Tuning - a course by Ahmed Baraka


Oracle Program Global Area (PGA)

Instance PGA

SQL Work Area Server


Session Memory Private SQL A. Process

SQL Work Area Server


Process
Session Memory Private SQL A.

Oracle© Database Performance Tuning - a course by Ahmed Baraka


About PGA
• A memory heap allocated for each server process
• Contents of the PGA:
- SQL Work Area: used to store data involved in memory-intensive
operations: sort area, hash area, and bitmap merge area
- Private SQL Area:
 Run-time area
 Persistent area
• PGA memory needed by a session depends on:
- Number of open cursors
- Memory used by PL/SQL, such as PL/SQL tables
- Amount of data to sort

Oracle© Database Performance Tuning - a course by Ahmed Baraka


Work Area Size Types

Optimal One-pass Multi-pass

The size of a work area is An extra pass is performed Multiple passes over
large enough to over part of the input data the input data are
accommodate the input data needed

Oracle© Database Performance Tuning - a course by Ahmed Baraka


PGA Memory Management Configurations
• Automatic Memory Management (AMM): SGA and PGA are
automatically sized
- MEMORY_TARGET is set to a positive value

• Automatic PGA memory management:


- MEMORY_TARGET is not set and PGA_AGGREGATE_TARGET is set

• Manual PGA memory management:


- WORKAREA_SIZE_POLICY is set to MANUAL
- SORT_AREA_SIZE , HASH_AREA_SIZE , BITMAP_MERGE_AREA_SIZE and
CREATE_BITMAP_AREA_SIZE (*_AREA_SIZE parameters)

Oracle© Database Performance Tuning - a course by Ahmed Baraka


Configuring Automatic PGA Memory
• PGA_AGGREGATE_TARGET
- Specifies the target aggregate PGA memory available to all server
processes attached to the instance
- Is a target, not a limit
- To specify a hard limit, configure the PGA_AGGREGATE_LIMIT

• WORKAREA_SIZE_POLICY
- Is automatically set to AUTO when PGA_AGGREGATE_TARGET is set to a
positive value
- Is automatically set to MANUAL when PGA_AGGREGATE_TARGET is set to
zero
- Can be set at the session level

Oracle© Database Performance Tuning - a course by Ahmed Baraka


Sizing PGA Guideline
• OLTP:
- 80% SGA
- 20% PGA

• DSS:
- 20% SGA
- 80% PGA

Oracle© Database Performance Tuning - a course by Ahmed Baraka


Obtaining Information about PGA Operations

V$SQL_WORKAREA

V$SQL V$SQL_PLAN

V$SQL_WORKAREA_ACTIVE

V$PGASTAT V$SYSSTAT

V$PROCESS_MEMORY V$SQL_WORKAREA_HISTOGRAM

Oracle© Database Performance Tuning - a course by Ahmed Baraka


PGA Wait Events
Event Triggered by
direct path write temp Sort operations that needed to be completed in a temporary
direct path read temp tablespace
direct path write Direct load operations
Parallel DML
direct path read FTS
direct path sync Wait for asynchronous I/O to complete
direct path read (lob) Writes to un-cached LOB segments
direct path write (lob)

• Check the following V$SESSION_WAIT parameter columns:


- P1 : file_id for the read call
- P2 : start block_id for the read call
- P3 : number of blocks in the read call
Oracle© Database Performance Tuning - a course by Ahmed Baraka
Operations that Require Sorting
• Database sorting is mainly required for the following operations:
- ORDER BY clause
- Aggregations: GROUP BY, ROLLUP, CUBE, WINDOW
- UNION/INTERSECT/MINUS Operations
- Index creation

Oracle© Database Performance Tuning - a course by Ahmed Baraka


PGA Statistics
• PGA statistics:
- workarea executions – optimal
- workarea executions – onepass
- workarea executions – multipass
- Number of sort (memory)
- Number of sort (disk)

Oracle© Database Performance Tuning - a course by Ahmed Baraka


Using V$PGASTAT

Statistic Description
aggregate PGA shows the current value of the PGA_AGGREGATE_TARGET
target parameter parameter.
aggregate PGA the amount of PGA memory Oracle Database can use for work
auto target areas that are running in automatic mode
total PGA the current amount of PGA memory allocated by the database
allocated instance.
over allocation How many times the instance needed to exceed the size set to the
count PGA_AGGREGATE_TARGET
cache hit The ratio of optimal executions
percentage

• Its history is saved in DBA_HIST_PGASTAT

Oracle© Database Performance Tuning - a course by Ahmed Baraka


Diagnosing PGA Performance Issues
• Possible issue:
- Work areas sizes are not enough for input data, temp disk is accessed

• Symptoms:
- Undersized PGA finding by ADDM
- Instance events:
 workarea executions – multipass
 Number of sort (disk)
- Top wait events: direct path write temp
- Low 'cache hit percentage' in V$PGASTAT

• Possible solutions: depends on the cause


- Increase the PGA size - SQL Tuning
- Avoid sorting
Oracle© Database Performance Tuning - a course by Ahmed Baraka
Using PGA Memory Advisory
SELECT ROUND(PGA_TARGET_FOR_ESTIMATE/1024/1024) TARGET_MB,
ESTD_PGA_CACHE_HIT_PERCENTAGE CACHE_HIT_PERC, ESTD_OVERALLOC_COUNT
FROM V$PGA_TARGET_ADVICE;

TARGET_MB CACHE_HIT_PERC ESTD_OVERALLOC_COUNT


---------- -------------- --------------------
13 96 55
25 96 55
38 96 55
...
80 97 55
90 97 55
100 97 55
150 99 17
200 100 0
300 100 0
400 100 0

Oracle© Database Performance Tuning - a course by Ahmed Baraka


Using PGA Memory Advisory in AWR Report

Oracle© Database Performance Tuning - a course by Ahmed Baraka


AWR Report: Process Memory Summary

Oracle© Database Performance Tuning - a course by Ahmed Baraka


Summary
In this lecture, you should have learnt how to perform the following:
• Understand PGA usage
• Describe work area size types
• Describe the possible PGA memory management configurations
• Configure the automatic PGA memory management
• Obtain information about PGA from V$ views
• Describe PGA wait events
• Describe PGA activity statistics
• Use V$PGASTAT
• Diagnose PGA Performance Issues
• Access PGA Memory Advisory
• Analyze 'Process Memory Summary' section in AWR reports
Oracle© Database Performance Tuning - a course by Ahmed Baraka

You might also like