ALTER SYSTEM FLUSH SHARED_POOL;
要注意的是,对于没有使用KEEP过程固定的序列号发生器,如果这些序列号发生器使用了缓冲,那么这些缓冲会被刷新,可能会导致序列号跳号。
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被清空了。
接下来,已sysdba的身份连接数据库,把seq_test keep起来,再看看会发生什么情况。
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
再用sysdba连接数据库,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
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9399028/viewspace-682402/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/9399028/viewspace-682402/