【11gR2新特性】DBMS_RESULT_CACHE管理結果快取的包
Oracle 11g提供了DBMS_RESULT_CACHE包來查詢SQL結果快取內容的狀態和適當地控制SQL結果快取內容。
DBMS_RESULT_CACHE功能和儲存過程
功能/儲存過程 描述
STATUS: 返回結果快取的當前狀態。值包括:
ENABLED: 結果快取是啟用的。
DISABLED:結果快取是不可用的。
BYPASSED:結果快取暫時不可用。
SYNC: 結果快取是可用的,但是目前正與其他RAC節點重新同步。
MEMORY_REPORT: 列出結果快取記憶體利用的一個概要(預設)或詳細的報表。
FLUSH: 推出整個結果快取的內容。
INVALIDATE: 使結果快取中一個特定物件的快取結果無效。
INVALIDATE_OBJECT: 根據快取ID使一特定結果快取無效。
下面透過具體的實驗給予介紹:
一 STATUS: 返回結果快取的當前狀態。
dbms_result_cache.status() from dual;
DBMS_RESULT_CACHE.STATUS()
--------------------------------------------------------
ENABLED
二 MEMORY_REPORT: 列出結果快取記憶體利用的一個概要(預設)或詳細的報表。檢視v$result_cache_statistics 是MEMORY_REPORT相同的描述
dbms_result_cache.memory_report();
R e s u l t C a c h e M e m o r y R e p o r t
[Parameters]
Block Size = 1K bytes
Maximum Cache Size = 15744K bytes (15744 blocks)
Maximum Result Size = 787K bytes (787 blocks)
[Memory]
Total Memory = 12704 bytes [0.001% of the Shared Pool]
... Fixed Memory = 12704 bytes [0.001% of the Shared Pool]
... Dynamic Memory = 0 bytes [0.000% of the Shared Pool]
PL/SQL procedure successfully completed.
* from v$result_cache_statistics;
ID NAME VALUE
---------- ------------------------------ ---------------------------------------------------------------------------------
1 Block Size (Bytes) 1024
2 Block Count Maximum 15744
3 Block Count Current 0
4 Result Size Maximum (Blocks) 787
5 Create Count Success 0
6 Create Count Failure 0
7 Find Count 0
8 Invalidation Count 0
9 Delete Count Invalid 0
10 Delete Count Valid 0
11 Hash Chain Length 0
12 Global Hit Count 0
13 Global Miss Count 0
13 rows selected.
autotrace on
/*+ result_cache */ count(*) from yangobj;
COUNT(*)
----------
74484
Execution Plan
----------------------------------------------------------
Plan hash value: 362321706
------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 297 (1)| 00:00:04 |
| 1 | RESULT CACHE | 7uz1ww4x7gs2a6ba4qjauzt4bq | | | |
| 2 | SORT AGGREGATE | | 1 | | |
| 3 | TABLE ACCESS FULL| YANGOBJ | 61204 | 297 (1)| 00:00:04 |
------------------------------------------------------------------------------------------
Result Cache Information (identified by operation id):
------------------------------------------------------
1 - column-count=1; dependencies=(YANG.YANGOBJ); attributes=(single-row); name="select /*+ result_cache */ count(*) from yangobj"
Note
-----
- dynamic sampling used for this statement (level=2)
Statistics
----------------------------------------------------------
9 recursive calls
4 db block gets
1126 consistent gets
0 physical reads
548 redo size
528 bytes sent via SQL*Net to client
520 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
COUNT(*)
----------
74484
Execution Plan
----------------------------------------------------------
Plan hash value: 362321706
------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 297 (1)| 00:00:04 |
| 1 | RESULT CACHE | 7uz1ww4x7gs2a6ba4qjauzt4bq | | | |
| 2 | SORT AGGREGATE | | 1 | | |
| 3 | TABLE ACCESS FULL| YANGOBJ | 61204 | 297 (1)| 00:00:04 |
------------------------------------------------------------------------------------------
Result Cache Information (identified by operation id):
------------------------------------------------------
1 - column-count=1; dependencies=(YANG.YANGOBJ); attributes=(single-row); name="select /*+ result_cache */ count(*) from yangobj"
Note
-----
- dynamic sampling used for this statement (level=2)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
0 consistent gets
0 physical reads
0 redo size
528 bytes sent via SQL*Net to client
520 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
從檢視v$result_cache_objects中獲取CACHE_ID。
name,status,cache_id from v$result_cache_objects;
NAME STATUS CACHE_ID
------------------------------ --------- -----------------------------------
YANG.YANGOBJ Published YANG.YANGOBJ
select /*+ result_cache */ cou Published 7uz1ww4x7gs2a6ba4qjauzt4bq
nt(*) from yangobj
三 INVALIDATE_OBJECT: 根據快取ID--CACHE_ID使一特定結果快取無效。
DBMS_RESULT_CACHE.INVALIDATE_OBJECT('7uz1ww4x7gs2a6ba4qjauzt4bq');
PL/SQL procedure successfully completed.
name,status,cache_id from v$result_cache_objects;
NAME STATUS CACHE_ID
------------------------------ --------- -----------------------------------
YANG.YANGOBJ Published YANG.YANGOBJ
select /*+ result_cache */ cou Invalid 7uz1ww4x7gs2a6ba4qjauzt4bq
nt(*) from yangobj
四 FLUSH: 清理整個結果快取的內容。
dbms_result_cache.memory_report();
R e s u l t C a c h e M e m o r y R e p o r t
[Parameters]
Block Size = 1K bytes
Maximum Cache Size = 2080K bytes (2080 blocks)
Maximum Result Size = 104K bytes (104 blocks)
[Memory]
Total Memory = 107812 bytes [0.049% of the Shared Pool]
... Fixed Memory = 9460 bytes [0.004% of the Shared Pool]
... Dynamic Memory = 98352 bytes [0.045% of the Shared Pool]
....... verhead = 65584 bytes
....... Cache Memory = 32K bytes (32 blocks)
........... Unused Memory = 26 blocks
........... Used Memory = 6 blocks
............... Dependencies = 3 blocks (3 count)
............... Results = 3 blocks
................... SQL = 2 blocks (2 count)
................... Invalid = 1 blocks (1 count)
PL/SQL 過程已成功完成。
已用時間: 00: 00: 00.35
dbms_result_cache.flush();
PL/SQL 過程已成功完成。
已用時間: 00: 00: 00.02
dbms_result_cache.memory_report();
R e s u l t C a c h e M e m o r y R e p o r t
[Parameters]
Block Size = 1K bytes
Maximum Cache Size = 2080K bytes (2080 blocks)
Maximum Result Size = 104K bytes (104 blocks)
[Memory]
Total Memory = 9460 bytes [0.004% of the Shared Pool]
... Fixed Memory = 9460 bytes [0.004% of the Shared Pool]
... Dynamic Memory = 0 bytes [0.000% of the Shared Pool]
PL/SQL 過程已成功完成。
已用時間: 00: 00: 00.02
結果快取已被清除。。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31444259/viewspace-2154262/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- SpringBoot快取管理(一) 預設快取管理Spring Boot快取
- MySQL:MySQL客戶端快取結果導致OOMMySql客戶端快取OOM
- iOS快取的總結iOS快取
- SpringBoot快取管理(二) 整合Redis快取實現Spring Boot快取Redis
- 面試總結 —— Redis “快取穿透”、“快取擊穿”、“快取雪崩”面試Redis快取穿透
- mysql group by 取想要的結果MySql
- 如何使用yii2的快取依賴特性快取
- 如何管理需要拼接的快取 Key快取
- 用Java寫一個分散式快取——快取管理Java分散式快取
- 014、映象的快取特性(2019-01-03 週四)快取
- Redis 快取雪崩,快取擊穿和快取穿透技術方案總結Redis快取穿透
- Kotlin 1.5.20 釋出了~快來看看新特性Kotlin
- Hadoop 集中式的快取管理demoHadoop快取
- 蘋果推出“蘋果邊緣快取”(蘋果企業簽名)蘋果快取
- STM32定時器觸發ADC多通道連續取樣,DMA快取結果定時器快取
- Redis 6.0 新特性篇:深度剖析客戶端快取(Client side caching)原理與效能Redis客戶端快取clientIDE
- PHP新特性之閉包、匿名函式PHP函式
- 快取原理與微服務快取自動管理快取微服務
- Java8常用的新特性總結Java
- Oracle 21c新特性預覽與日常管理相關的幾個新特性Oracle
- 獲取任務的執行結果
- MySQL 8.0 18個管理相關的新特性MySql
- html5新特性總結HTML
- ES6新特性總結
- React 16 新特性使用總結React
- JDK1.8新特性總結JDK
- css3新特性總結CSSS3
- vue中methods中的方法閉包快取問題Vue快取
- SpringBoot快取管理(三) 自定義Redis快取序列化機制Spring Boot快取Redis
- 013、Vue3+TypeScript基礎,computed計算屬性的使用,結果會被快取VueTypeScript快取
- Go1.14 釋出了,快來圍觀新的特性啦Go
- Redis的快取穿透、快取雪崩、快取擊穿的區別Redis快取穿透
- JDK 1.5 - 1.8 各版本的新特性總結JDK
- 個人總結-CPU快取快取
- 蘋果WWDC18最全總結 四大系統新特性彙總蘋果
- Sql_從查詢的結果集中分組後取最後有效的資料成新的結果集小記(待優化)SQL優化
- .NET 9中新快取HybridCache快取
- 如何在SPRING中同時管理本地快取和分散式快取? - techblogSpring快取分散式