You are on page 1of 4

һ��ʹ���˴��ı���SQL��ϵͳ������һ��ʱ��

� ���
�� �ֹ���
‫�ִ��س‬ ��Ƭ����ʱ����‫�������������½����ܻ����ص‬£�ˢ�¹���
�‫ָ�����ص���ܡ‬
���� �‫� ػ‬

ʹ�������������ˢ�¹���‫�أ‬
ALTER SYSTEM FLUSH SHARED_POOL;

Ҫ ‫���ע‬ʱ��ˢ�¹���
��ʹ���е�û��ʹ��DBMS_SHARED_POOL.KEEP����Ķ���ȫ����������Թ���‫ظ‬ո� ˢ� µ� ʱ� � S
QL��PL/SQL��ִ��Ч�ʻ�����½����Ҫ���� ‫װ�غ‬ͷ�����ЩSQL ��PL/SQL ������� �ܿ�ϵͳ
�����ܻ��� ������߲ˢ��ǰ��
�����

Ҫ ‫����ע‬ǣ� � ��� û�� ʹ� � KEEP� ���� �����


кŷ ����������
٠���
кŷ ����� ʹ 壬�
� �� ˻
��
�ô��Щ����� ˢ�£����ܻᵼ�����к���š�

The DBMS_SHARED_POOL package provides procedures that allow PL/SQL objects and
SQL cursors to be pinned (kept) in the Oracle shared pool. Once pinned, objects are
not subject to the normal aging-out processes of the shared pool��

DBMS_SHARED_POOL is used primarily by DBAs to help solve memory management and


performance issues that can arise when applications make use of large PL/SQL
objects or SQL cursors. Two problems can arise when large objects need to be loaded
into the shared pool:

ORA-04031 errors where insufficient memory is available and the user call fails
to execute.

Degraded performance due to the memory management overhead involved in finding


and making room to load large objects.

Pinning large objects into the shared pool when the Oracle instance is first
started can reduce or eliminate these problems. Some DBAs use DBMS_SHARED_POOL in
their database startup scripts to help ensure that shared pool memory is used
efficiently��

The DBMS_SHARED_POOL package is created when the Oracle database is installed.


The dbmspool.sql script. (found in the built-in packages source code directory, as
described in Chapter 1 ) contains the source code for this package's specification.
Unlike many of the other built-in package scripts, this script. is not called by
catproc.sql . Thus, the DBA must manually build this package. This is accomplished
by executing the dbmspool.sql and prvtpool.plb scripts (in order) from SQLDBA or
Server Manager when connected as the INTERNAL user.

Access to the DBMS_SHARED_POOL package is not automatically granted to any


users, nor is a public synonym referencing the package created. The package is
intended for use strictly by the Oracle DBA, usually when connected as the SYS
user. Under Oracle8, the EXECUTE_CATALOG_ROLE role is granted EXECUTE privilege on
DBMS_SHARED_POOL, so any users with this role can use the package.
KEEP Procedure

This procedure keeps an object in the shared pool. Once an object has been kept in
the shared pool, it is not subject to aging out of the pool. This may be useful for
frequently used large objects. When large objects are brought into the shared pool,
several objects may need to be aged out to create a contiguous area large enough.

Syntax

DBMS_SHARED_POOL.KEEP (
name VARCHAR2,
flag CHAR DEFAULT 'P');

Parameters

Table 97-3 KEEP Procedure Parameters


Parameter Description

name

Name of the object to keep.

The value for this identifier is the concatenation of the address and hash_value
columns from the v$sqlarea view. This is displayed by the SIZES procedure.

Currently, TABLE and VIEW objects may not be kept.

flag

(Optional) If this is not specified, then the package assumes that the first
parameter is the name of a package/procedure/function and resolves the name.

Set to 'P' or 'p' to fully specify that the input is the name of a
package/procedure/function.

Set to 'T' or 't' to specify that the input is the name of a type.

Set to 'R' or 'r' to specify that the input is the name of a trigger.

Set to 'Q' or 'q' to specify that the input is the name of a sequence.

In case the first argument is a cursor address and hash-value, the parameter should
be set to any character except 'P' or 'p' or 'Q' or 'q' or 'R' or 'r' or 'T' or
't'.

SQL> @?/rdbms/admin/dbmspool.sql

������Ѵ�����

��Ȩ�ɹ���

��ͼ�Ѵ�����

��������Ѵ�����

SQL> @?/rdbms/admin/prvtpool.plb

��ͼ�Ѵ�����

��������Ѵ�����

�ú�
��������� �Ϳ�
ʼ�
���
����
��ˢ�

¹ � е 飺
SQL> create sequence seq_test;

�����Ѵ�����

SQL> select seq_test.nextval from dual;

NEXTVAL
----------
1

SQL> alter system flush shared_pool;

ϵͳ�Ѹ�ġ�

SQL> select seq_test.nextval from dual;

NEXTVAL
----------
21

��ʾ������flush ����‫�أ‬sequence��cache������ˡ�

����4����sysdba�����l����‫ݿ‬⣬��seq_test keep ��4 ��� ��ʲ


� �
‫��� ����ٿ‬

SQL> exec dbms_shared_pool.keep('test.seq_test','q');

PL/SQL ����ѳɹ���ɡ�

SQL>

��ˢ�¹���‫��������أ‬

SQL> select seq_test.nextval from dual;

NEXTVAL
----------
22

SQL> alter system flush shared_pool;

ϵͳ�Ѹ�ġ�

SQL> select seq_test.nextval from dual;

NEXTVAL
----------
23

����sysdbal����‫ݿ‬⣬unkeep�����С�

SQL> exec dbms_shared_pool.unkeep('test.seq_test','q');

PL/SQL ����ѳɹ���ɡ�

�‫���ٳ‬ˢ��shared_pool��

SQL> select seq_test.nextval from dual;

NEXTVAL
----------
24

SQL> alter system flush shared_pool;

ϵͳ�Ѹ�ġ�

SQL> select seq_test.nextval from dual;

NEXTVAL
----------
41

You might also like