Tải bản đầy đủ (.ppt) (38 trang)

Sizing the Shared Pool pdf

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (211.53 KB, 38 trang )

4

Sizing the Shared Pool

Copyright © Oracle Corporation, 2002. All rights reserved.


Objectives
After completing this lesson, you should be able to do
the following:
• Determine the size of an object and pin it in the
shared pool
• Tune the shared pool reserved space
• Describe the user global area (UGA) and session
memory considerations
• Measure the library cache hit ratio
• List other tuning issues related to the shared pool
• Measure the dictionary cache hit ratio
• Set the large pool
4-2

Copyright © Oracle Corporation, 2002. All rights reserved.


Shared Pool Contents
Major components of the shared pool are:
• Library cache
• Data dictionary cache
• User global area (UGA) for shared server sessions
Database
buffer


cache

Redo
log
buffer

Shared pool
Library cache

UGA
Data dictionary cache

User global area

4-3

Large
pool

Copyright © Oracle Corporation, 2002. All rights reserved.


Shared Pool






Defined by SHARED_POOL_SIZE

Library cache contains statement text, parsed
code, and execution plan.
Data dictionary cache contains definitions for
tables, columns, and privileges from the data
dictionary tables.
UGA contains session information for Oracle
Shared Server users when a large pool is not
configured.
Shared pool
Library
cache

Shared pool

Shared pool
Data
dictionary
cache
UGA
4-4

Copyright © Oracle Corporation, 2002. All rights reserved.


The Library Cache




4-5


Used to store SQL statements and PL/SQL blocks
to be shared by users
Managed by a least recently used (LRU) algorithm
Used to prevent statements reparsing

Copyright © Oracle Corporation, 2002. All rights reserved.


The Library Cache

Shared SQL, PL/SQL areas
Context area
for SELECT
statement 2

Context area
for SELECT
statement 1

SELECT
statement 2

4-6

SELECT
statement 1

SELECT
statement 1


Copyright © Oracle Corporation, 2002. All rights reserved.


Important Shared Pool Latches



4-7

shared pool: Protects memory allocations in the
shared pool
library cache: Locates matching SQL in the
shared pool

Copyright © Oracle Corporation, 2002. All rights reserved.


Shared Pool and Library Cache Latches
Contention for shared pool latch and library cache
latch indicates one or more of the following:
• Unshared SQL
ã Reparsed sharable SQL
ã Insufficiently sized library cache

4-8

Copyright â Oracle Corporation, 2002. All rights reserved.



Tuning the Library Cache
Reduce misses by keeping parsing to a minimum:
• Make sure that users can share statements.
• Prevent statements from being aged out by
allocating enough space.
• Avoid invalidations that induce reparsing.

4-9

Copyright © Oracle Corporation, 2002. All rights reserved.


Tuning the Library Cache
Avoid fragmentation by:
• Reserving space for large memory requirements
• Pinning frequently required large objects
• Eliminating large anonymous PL/SQL blocks
• Enabling the use of large pool for Oracle Shared
Server connections

4-10

Copyright © Oracle Corporation, 2002. All rights reserved.


Terminology







4-11

Gets: (Parse) The number of lookups for objects
of the namespace
Pins: (Execution) The number of reads or
executions of the objects of the namespace
Reloads: (Parse) The number of library cache
misses on the execution step, thereby causing an
implicit reparsing of the SQL statement
Invalidations: (Parse) If an object is modified then
all explain plans that reference the object are
marked invalid and must be parsed again.

Copyright © Oracle Corporation, 2002. All rights reserved.


Diagnostic Tools
for Tuning the Library Cache
v$sgastat
v$librarycache
Views

Shared pool

Library cache
Shared SQL

v$sql


sp_m_n.lst

and PL/SQL

v$sqlarea
v$sqltext
v$db_object_cach
e

Data dictionary
cache

report.txt

UGA

Parameters affecting the components:
SHARED_POOL_SIZE, OPEN_CURSORS
SESSION_CACHED_CURSORS, CURSOR_SPACE_FOR_TIME
CURSOR_SHARING, SHARED_POOL_RESERVED_SIZE
4-12

Copyright © Oracle Corporation, 2002. All rights reserved.


Are Cursors Being Shared?


Check gethitration in v$librarycache:


SQL> SELECT gethitratio
2 FROM v$librarycache
3 WHERE namespace = 'SQL AREA';



Determine which statements users are running:

SQL> SELECT sql_text, users_executing,
2
executions, loads
3
FROM v$sqlarea;
SQL> SELECT * FROM v$sqltext
2
WHERE sql_text LIKE
3
'SELECT * FROM hr.employees WHERE %';
4-13

Copyright © Oracle Corporation, 2002. All rights reserved.


Sharing Cursors

Values for CURSOR_SHARING are:
ã Exact
ã Similar
ã Force


4-14

Copyright â Oracle Corporation, 2002. All rights reserved.


Guidelines: Library Cache Reloads


Reloads should be less than 1% of the pins:

SQL> SELECT SUM(pins) "Executions",
2
SUM(reloads) "Cache Misses",
3
SUM(reloads)/SUM(pins)
4 FROM v$librarycache;



If the reloads-to-pins ratio is greater than 1%,
increase the value of the SHARED_POOL_SIZE
parameter.
Executes PROC1 —> 1st pin, 1 load
Executes PROC1 —> 2nd pin, no reload
Executes PROC1 —> 3rd pin, no reload
Executes PROC1 —> 4th pin, no reload

4-15


Copyright © Oracle Corporation, 2002. All rights reserved.

4 pins and
no reloads


Invalidations
The number of times objects of the namespace were
marked invalid, causing reloads:
SQL>
SQL>
2
3
SQL>
>
SQL>
SQL>
2
3
4-17

SELECT count(*) FROM hr.employees;
SELECT namespace,pins,reloads,
invalidations
FROM v$librarycache;
execute dbms_stats.gather_table_stats ('HR','EMPLOYEES');
SELECT count(*) FROM hr.employees;
SELECT namespace,pins,reloads,
invalidations
FROM v$librarycache;

Copyright © Oracle Corporation, 2002. All rights reserved.


Sizing the Library Cache






4-19

Define the global space necessary for stored
objects (packages, views, and so on).
Define the amount of memory used by the usual
SQL statements.
Reserve space for large memory requirements to
avoid misses and fragmentation.
Pin frequently used objects.
Convert large anonymous PL/SQL blocks
into small anonymous blocks calling
packaged functions.

Copyright © Oracle Corporation, 2002. All rights reserved.


Shared Pool Advisory
SQL> SELECT shared_pool_size_for_estimate AS
2
pool_size, estd_lc_size,

3
estd_lc_time_saved
4 FROM v$shared_pool_advice;
POOL_SIZE ESTD_LC_SIZE ESTD_LC_TIME_SAVED
---------- ------------ -----------------32
8
7868
40
15
7868
48
17
7868
56
17
7868
64
17
7868
72
17
7868
80
17
7868
88
17
7868
4-20


Copyright © Oracle Corporation, 2002. All rights reserved.


Oracle Enterprise Manager
Shared Pool Size Advisor

4-22

Copyright © Oracle Corporation, 2002. All rights reserved.


Cached Execution Plans






4-23

With this feature, the Oracle server preserves the
actual execution plan of a cached SQL statement
in memory.
When the SQL statement ages out of the library
cache, the corresponding cached execution plan
is removed.
The main benefit of this feature is better diagnosis
of query performance.

Copyright © Oracle Corporation, 2002. All rights reserved.



Views to Support
Cached Execution Plans
You can use the v$sql_plan dynamic performance
view to view the actual execution plan information for
cached cursors.
SQL> SELECT operation, object_owner,
2
object_name, cost
3 FROM v$sql_plan
4 ORDER BY hash_value;

4-24

Copyright © Oracle Corporation, 2002. All rights reserved.


Support For Cached Execution Plans





4-25

The v$sql view has a column, plan_hash_value,
which references the hash_value column of
v$sql_plan.
The column information is a hash value built from

the corresponding execution plan.
The column can be used to compare cursor plans
the same way the hash_value column is used to
compare cursor SQL texts.

Copyright © Oracle Corporation, 2002. All rights reserved.


Global Space Allocation
Stored objects such as packages and views:
SQL> SELECT SUM(sharable_mem)
2
FROM v$db_object_cache;
SUM(SHARABLE_MEM)
----------------SQL statements:
SQL> SELECT379600
SUM(sharable_mem)
2
FROM v$sqlarea WHERE executions > 5;
SUM(SHARABLE_MEM)
----------------4-26

381067

Copyright © Oracle Corporation, 2002. All rights reserved.


Large Memory Requirements




Satisfy requests for large contiguous memory
Reserve contiguous memory within the
shared pool
Shared pool

v$shared_pool_reserved

Library cache
Shared SQL
and PL/SQL

SHARED_POOL_SIZE
SHARED_POOL_RESERVED_SIZE

Data dictionary
cache

UGA

4-28

Copyright © Oracle Corporation, 2002. All rights reserved.


Tuning the Shared Pool
Reserved Space


Diagnostic tools for tuning:

– The v$shared_pool_reserved dictionary view
– The supplied aborted_request_threshold
procedure in the dbms_shared_pool package



4-30

Guidelines: Set the
SHARED_POOL_RESERVED_SIZE parameter

Copyright © Oracle Corporation, 2002. All rights reserved.


Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×