DBMS_SHARED_POOL 사용을 하여 원하는 SQL문을 FLUSH 수행.
그럼 언제 사용이 좋은것 같을까요 ?
1. 성능테스트 진행 할때
2. sql 튜닝을 할때.
저는 우선 위의 두가지 경우에 사용을 많이 합니다.
사용방법은 MOS 에 아주 상세히 잘 나와 있고요.
또는 검색을 통해서도 잘 찾아서 볼수 있습니다.
MOS 요약은 아래와 같습니다.
procedure purge (name varchar2, flag char DEFAULT 'P', heaps number DEFAULT 1);
Explanation: Purge the named object or particular heap(s) of the object.
Input arguments:
name: The name of the object to purge.
There are two kinds of objects:
PL/SQL objects, triggers, sequences, types and Java objects which are specified by name,
SQL cursor objects which are specified by a twopart number. The value for this identifier
is the concatenation of the 'address' and 'hash_value' columns from the v$sqlarea view.
flag: This is an optional parameter. If the parameter is not specified,
the package assumes that the first parameter is the name of a
package/procedure/function and will resolve the name. Otherwise,
the parameter is a character string indicating what kind of object
to purge the name identifies. The string is case insensitive.
The possible values and the kinds of objects they indicate are
given in the following table:
Value Kind of Object to keep
----- ----------------------
P package/procedure/function
Q sequence
R trigger
T type
JS java source
JC java class
JR java resource
JD java shared data
C cursor
heaps: heaps to purge. e.g if heap 0 and heap 6 are to be purged.
1<<0 | 1< Default is 1 i.e heap 0 which means the whole object will be purged.
Explanation: Purge the named object or particular heap(s) of the object.
Input arguments:
name: The name of the object to purge.
There are two kinds of objects:
PL/SQL objects, triggers, sequences, types and Java objects which are specified by name,
SQL cursor objects which are specified by a twopart number. The value for this identifier
is the concatenation of the 'address' and 'hash_value' columns from the v$sqlarea view.
flag: This is an optional parameter. If the parameter is not specified,
the package assumes that the first parameter is the name of a
package/procedure/function and will resolve the name. Otherwise,
the parameter is a character string indicating what kind of object
to purge the name identifies. The string is case insensitive.
The possible values and the kinds of objects they indicate are
given in the following table:
Value Kind of Object to keep
----- ----------------------
P package/procedure/function
Q sequence
R trigger
T type
JS java source
JC java class
JR java resource
JD java shared data
C cursor
heaps: heaps to purge. e.g if heap 0 and heap 6 are to be purged.
1<<0 | 1< Default is 1 i.e heap 0 which means the whole object will be purged.
SESSION 1
sqlplus scott/tiger
SQL> select ename from emp where empno=7900;
SESSION 2
sqlplus / as sysdba
SQL> select address, hash_value, executions, loads, version_count, invalidations, parse_calls
from v$sqlarea
where sql_text = 'select ename from emp where empno=7900';
ADDRESS HASH_VALUE EXECUTIONS LOADS VERSION_COUNT INVALIDATIONS PARSE_CALLS
---------------- ---------- ---------- ---------- ------------- ------------- -----------
000000007A6CF430 1052545619 1 1 1 0 1
SQL> exec dbms_shared_pool.purge ('000000007A6CF430,1052545619 ','C');
SQL> select address, hash_value, executions, loads, version_count, invalidations, parse_calls
from v$sqlarea
where sql_text = 'select ename from emp where empno=7900';
no rows selected
sqlplus scott/tiger
SQL> select ename from emp where empno=7900;
SESSION 2
sqlplus / as sysdba
SQL> select address, hash_value, executions, loads, version_count, invalidations, parse_calls
from v$sqlarea
where sql_text = 'select ename from emp where empno=7900';
ADDRESS HASH_VALUE EXECUTIONS LOADS VERSION_COUNT INVALIDATIONS PARSE_CALLS
---------------- ---------- ---------- ---------- ------------- ------------- -----------
000000007A6CF430 1052545619 1 1 1 0 1
SQL> exec dbms_shared_pool.purge ('000000007A6CF430,1052545619 ','C');
SQL> select address, hash_value, executions, loads, version_count, invalidations, parse_calls
from v$sqlarea
where sql_text = 'select ename from emp where empno=7900';
no rows selected
NOTE: The PURGE procedure was introduced in Oracle 11g and will be included in the 10.2.0.4 patch set release. The purge procedure is event-protected in 10.2.0.4 and needs to be enabled through event 5614566, please see Note:751876.1 for more information. Some patches are available for some platforms with versions 10.2.0.2 and 10.2.0.3, downloadable as Patch:5614566.
저는 아래 처럼 기본틀을 잡아 놓은 상태에서 사용 합니다.
SELECT 'EXEC SYS.DBMS_SHARED_POOL.PURGE ('''|| ADDRESS ||',' || HASH_VALUE ||''',''C'');', SA.SQL_ID,
PARSING_SCHEMA_NAME, ADDRESS, HASH_VALUE, EXECUTIONS, LOADS, VERSION_COUNT, INVALIDATIONS, PARSE_CALLS,
DBMS_LOB.GETLENGTH(SQL_FULLTEXT) AS "SQL_LENS" , DBMS_LOB.SUBSTR(SQL_FULLTEXT, 320,1) SQL_FULLTEXT
FROM V$SQLAREA SA
PARSING_SCHEMA_NAME, ADDRESS, HASH_VALUE, EXECUTIONS, LOADS, VERSION_COUNT, INVALIDATIONS, PARSE_CALLS,
DBMS_LOB.GETLENGTH(SQL_FULLTEXT) AS "SQL_LENS" , DBMS_LOB.SUBSTR(SQL_FULLTEXT, 320,1) SQL_FULLTEXT
FROM V$SQLAREA SA
출처
How To Flush an Object Out The Library Cache [SGA] Using The DBMS_SHARED_POOL Package (Doc ID 457309.1)
댓글 0
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
10 | events 활용 (10384,10046,10053 ) MOS 기준 [2] | 우뽕 | 2023.04.06 | 660 |
9 | 튜닝시 SQL 문장의 OutLine 정보를 추출하는 SQL 문장 | 명품관 | 2021.01.14 | 35584 |
8 | SQL Advisor 사용법을 이용한 튜닝 가이드 | 우뽕 | 2020.04.09 | 3518 |
7 | [12cR1 이상] Limiting SQL Rows 활용하여 페이징 처리 해 보기 [1] | 우뽕 | 2020.03.27 | 2068 |
6 | DB 유저가 DBMS_XPLAN 패키기 사용시 필요한 권한 | 명품관 | 2020.03.20 | 1329 |
» | DBMS_SHARED_POOL 사용 | 우뽕 | 2020.03.11 | 1014 |
4 | Column 를 이용한 hint 사용하기 [1] | 우뽕 | 2020.02.28 | 1972 |
3 | _smu_debug_mode 와_undo_autotune 관련 내용 정리 | 우뽕 | 2020.01.23 | 1241 |
2 | [12cR2 이상] _cursor_obsolete_threshold 기본값으로 변경 하기 | 우뽕 | 2020.01.23 | 1382 |
1 | V$SQL_HINT를 통해 HINT 종류 확인 | 명품관 | 2019.05.29 | 778 |