Oracle7 Server Tuning | ![]() Library |
![]() Product |
![]() Contents |
![]() Index |
This chapter explains the use of shared SQL to improve performance. Topics in this chapter include
Shared SQL and PL/SQL areas are shared memory areas; any Oracle process can use a shared SQL area. The use of shared SQL areas reduces memory usage on the database server, thereby increasing system throughput.
Shared SQL and PL/SQL areas are aged out of the shared pool by way of a least recently used algorithm (similar to database buffers). To improve performance and prevent reparsing, you may want to prevent large SQL or PL/SQL areas from aging out of the shared pool.
SELECT * FROM emp;
is not considered identical because the statement references different tables for each user.
Within an application there is a very minimal advantage to having 2 statements almost the same, and 300 users using them, versus having one statement used by 600 users.
By using the DBMS_SHARED_POOL package and by loading these SQL and PL/SQL areas early (before memory fragmentation occurs), the objects can be kept in memory, instead of aging out with the normal LRU mechanism. This procedure ensures that memory is available and prevents sudden, seemingly inexplicable slowdowns in user response time that occur when SQL and PL/SQL areas are accessed after aging out.
When large PL/SQL objects are loaded, users' response time is affected because of the large number of smaller objects that need to be aged out from the shared pool to make room (due to memory fragmentation). In some cases, there may be insufficient memory to load the large objects.
DBMS_SHARED_POOL is also useful for frequently executed triggers. You may want to keep compiled triggers on frequently used tables in the shared pool.
The procedures provided with the DBMS_SHARED_POOL package are described below.
dbms_shared_pool.sizes(minsize IN NUMBER)
Input Parameter:
minsize
Display objects in shared pool larger than this size, where size is measured in kilobytes.
Output Parameters:
To display the results of this procedure, before calling this procedure issue the following command using Server Manager or SQL*Plus:
SET SERVEROUTPUT ON SIZE minsize
You can use the results of this command as arguments to the KEEP or UNKEEP procedures.
For example, to show the objects in the shared pool that are larger than 2000 you would issue the following Server Manager or SQL*Plus commands:
SQL> SET SERVEROUTPUT ON SIZE 2000
SQL> EXECUTE DBMS_SHARED_POOL.SIZES(2000);
dbms_shared_pool.keep(object IN VARCHAR2,
[type IN CHAR DEFAULT P])
Input Parameters:
object
Either the parameter name or the cursor address of the object that you want kept in the shared pool. This is the value displayed when you call the SIZES procedure.
type
The type of the object that you want kept in the shared pool. The types recognized are listed below:
Note: This procedure may not be supported in the future.
dbms_shared_pool.unkeep(object IN VARCHAR2,
[type IN CHAR DEFAULT P])
Input Parameters:
object
Either the parameter name or the cursor address of the object that you no longer want kept in the shared pool. This is the value displayed when you call the SIZES procedure.
type
The type of the object that you want aged out of the shared pool. The following types are recognized:
![]() ![]() Prev Next |
![]() Copyright © 1996 Oracle Corporation. All Rights Reserved. |
![]() Library |
![]() Product |
![]() Contents |
![]() Index |