11G can flush one SQL Cursor out of shared pool
在11G之前(準確的說在10204之前),當我們需要flush一些literal SQL out of shared pool時,我們馬上想到的是對於這個SQL所在的object上做一些DDL使其馬上被flush出shared pool。例如:
under 10G:
SQL> select ADDRESS,HASH_VALUE,EXECUTIONS from v$sqlarea where SQL_TEXT like 'select count(*) from testsqlsql%';
ADDRESS HASH_VALUE EXECUTIONS
---------------- ---------- ----------
00000003ADA4FFB8 4184050671 2
SQL> grant select on testsqlsql to dba;
Grant succeeded.
SQL> select ADDRESS,HASH_VALUE,EXECUTIONS from v$sqlarea where SQL_TEXT like 'select count(*) from testsqlsql%';
no rows selected
但是11G開始這招不靈了。
做DDL只是將這個objects相關的SQL標誌為INVALID,然後下次執行時才被清除。
under 11G:
SQL> select ADDRESS,HASH_VALUE,EXECUTIONS,SHARABLE_MEM,OBJECT_STATUS
2 from v$sqlarea where SQL_TEXT like 'select count(*) from testsqlsql%';
ADDRESS HASH_VALUE EXECUTIONS SHARABLE_MEM OBJECT_STATUS
---------------- ---------- ---------- ------------ -------------------
000000039FCBEBE0 4184050671 1 14656 VALID
SQL> grant select on testsqlsql to dba;
Grant succeeded.
SQL> select ADDRESS,HASH_VALUE,EXECUTIONS,SHARABLE_MEM,OBJECT_STATUS
2 from v$sqlarea where SQL_TEXT like 'select count(*) from testsqlsql%';
ADDRESS HASH_VALUE EXECUTIONS SHARABLE_MEM OBJECT_STATUS
---------------- ---------- ---------- ------------ -------------------
000000039FCBEBE0 4184050671 1 14656 INVALID_UNAUTH
一般情況下是沒問題的,但是如果我們希望flush一些literal SQL或者佔用shared pool非常之大的SQL,而且希望他們馬上消失,這時我們需要其他的辦法。
就是11G的dbms_shared_pool.purge。(準確的說10204就有了,只是有一些bug)。
PROCEDURE PURGE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
NAME VARCHAR2 IN
FLAG CHAR IN DEFAULT
HEAPS NUMBER IN DEFAULT
如果對於SQL cursor來說,NAME引數的格式是ADDR,HASH_VALUE from v$sqlarea。
FLAG引數標明瞭NAME引數的種類,對於SQL Cursor來說,FLAG只要不為'P' or 'p' or 'Q' or 'q' or 'R' or 'r' or 'T' or 't'即可。所以在其他的文章中,為了flush一個SQL Cursor,FLAG常被設為'C',其實設為其他任何字母都沒問題。
HEAPS引數為1代表所有heaps都被purge。即:
SQL> select ADDRESS,HASH_VALUE,EXECUTIONS,SHARABLE_MEM,OBJECT_STATUS
2 from v$sqlarea where SQL_TEXT like 'select count(*) from testsqlsql%';
ADDRESS HASH_VALUE EXECUTIONS SHARABLE_MEM OBJECT_STATUS
---------------- ---------- ---------- ------------ -------------------
000000039FCBEBE0 4184050671 1 14656 INVALID_UNAUTH
SQL> exec sys.dbms_shared_pool.purge('000000039FCBEBE0,4184050671','C',1);
PL/SQL procedure successfully completed.
SQL> select ADDRESS,HASH_VALUE,EXECUTIONS,SHARABLE_MEM,OBJECT_STATUS
2 from v$sqlarea where SQL_TEXT like 'select count(*) from testsqlsql%';
no rows selected
under 10G:
SQL> select ADDRESS,HASH_VALUE,EXECUTIONS from v$sqlarea where SQL_TEXT like 'select count(*) from testsqlsql%';
ADDRESS HASH_VALUE EXECUTIONS
---------------- ---------- ----------
00000003ADA4FFB8 4184050671 2
SQL> grant select on testsqlsql to dba;
Grant succeeded.
SQL> select ADDRESS,HASH_VALUE,EXECUTIONS from v$sqlarea where SQL_TEXT like 'select count(*) from testsqlsql%';
no rows selected
但是11G開始這招不靈了。
做DDL只是將這個objects相關的SQL標誌為INVALID,然後下次執行時才被清除。
under 11G:
SQL> select ADDRESS,HASH_VALUE,EXECUTIONS,SHARABLE_MEM,OBJECT_STATUS
2 from v$sqlarea where SQL_TEXT like 'select count(*) from testsqlsql%';
ADDRESS HASH_VALUE EXECUTIONS SHARABLE_MEM OBJECT_STATUS
---------------- ---------- ---------- ------------ -------------------
000000039FCBEBE0 4184050671 1 14656 VALID
SQL> grant select on testsqlsql to dba;
Grant succeeded.
SQL> select ADDRESS,HASH_VALUE,EXECUTIONS,SHARABLE_MEM,OBJECT_STATUS
2 from v$sqlarea where SQL_TEXT like 'select count(*) from testsqlsql%';
ADDRESS HASH_VALUE EXECUTIONS SHARABLE_MEM OBJECT_STATUS
---------------- ---------- ---------- ------------ -------------------
000000039FCBEBE0 4184050671 1 14656 INVALID_UNAUTH
一般情況下是沒問題的,但是如果我們希望flush一些literal SQL或者佔用shared pool非常之大的SQL,而且希望他們馬上消失,這時我們需要其他的辦法。
就是11G的dbms_shared_pool.purge。(準確的說10204就有了,只是有一些bug)。
PROCEDURE PURGE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
NAME VARCHAR2 IN
FLAG CHAR IN DEFAULT
HEAPS NUMBER IN DEFAULT
如果對於SQL cursor來說,NAME引數的格式是ADDR,HASH_VALUE from v$sqlarea。
FLAG引數標明瞭NAME引數的種類,對於SQL Cursor來說,FLAG只要不為'P' or 'p' or 'Q' or 'q' or 'R' or 'r' or 'T' or 't'即可。所以在其他的文章中,為了flush一個SQL Cursor,FLAG常被設為'C',其實設為其他任何字母都沒問題。
HEAPS引數為1代表所有heaps都被purge。即:
SQL> select ADDRESS,HASH_VALUE,EXECUTIONS,SHARABLE_MEM,OBJECT_STATUS
2 from v$sqlarea where SQL_TEXT like 'select count(*) from testsqlsql%';
ADDRESS HASH_VALUE EXECUTIONS SHARABLE_MEM OBJECT_STATUS
---------------- ---------- ---------- ------------ -------------------
000000039FCBEBE0 4184050671 1 14656 INVALID_UNAUTH
SQL> exec sys.dbms_shared_pool.purge('000000039FCBEBE0,4184050671','C',1);
PL/SQL procedure successfully completed.
SQL> select ADDRESS,HASH_VALUE,EXECUTIONS,SHARABLE_MEM,OBJECT_STATUS
2 from v$sqlarea where SQL_TEXT like 'select count(*) from testsqlsql%';
no rows selected
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15415488/viewspace-627066/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Flush an Object Out The Library Cache [SGA] Using The DBMS_SHARED_POOLObject
- shared SQL,parent cursor,child cursorSQL
- 【Shared Pool】使用DBMS_SHARED_POOL包將PL/SQL大物件儲存到Shared PoolSQL物件
- sql_shared_cursor (轉)SQL
- shared_pool_spare_free.sqlSQL
- 【實驗】shared_pool的sql命中率--cursor_sharing引數研究SQL
- PL/SQL Program Units and the Shared Pool (89)SQL
- 使用DBMS_SHARED_POOL包將PL/SQL大物件儲存到Shared PoolSQL物件
- shared_pool的sql命中率SQL
- cursor_sharing與v$sqlarea_v$sql_v$sql_shared_cursorSQL
- Oracle shared poolOracle
- v$sql v$sqlarea v$sql_shared_cursor及遊標SQL
- _shared_pool_reserved_pct or shared_pool_reserved_size with ASMMASM
- v$sql_shared_cursor中的BIND_MISMATCHSQL
- zt_Oracle shared pool internals_共享池_shared_poolOracle
- SHARED POOL總結
- SHARED_POOL解析
- 理解Oracle Shared PoolOracle
- flush sqlSQL
- 【CURSOR】Oracle 子游標無法共享的原因之V$SQL_SHARED_CURSOROracleSQL
- V$SQL_SHARED_CURSOR檢視硬解析的原因SQL
- SQL在shared pool中的解析過程問題SQL
- Can one execute an operating system command from PL/SQL?SQL
- 【PL/SQL】在PL/SQL中執行重新整理Shared Pool命令SQL
- sql執行計劃_v$sqlarea_v$sql_v$sql_shared_cursorSQL
- Oracle Shared Pool Memory ManagementOracle
- ORACLE SGA之shared poolOracle
- SQL Plan Baseline與Shared Cursor機制研究(一)SQL
- SQL Plan Baseline與Shared Cursor機制研究(二)SQL
- SQL Plan Baseline與Shared Cursor機制研究(三)SQL
- 清除shared pool中某條sql的執行計劃SQL
- 共享SQL區在shared pool中釋放的條件SQL
- dbms_shared_pool keep物件到share pool中物件
- v$sql v$sqlarea v$sql_shared_cursor及父遊標,子游標SQL
- v$sql_shared_cursor檢視記錄多版本的資訊SQL
- dbms_shared_pool.purge 清理某個SQL執行計劃SQL
- SHARED POOL 基礎知識
- 簡單分析shared pool(一)