11g新特性--result caching
開啟result_cache後,sql的查詢結果被快取到shared_pool中,再次執行相同的查詢時,直接讀取結果,不需要執行該sql了,可以通過兩種方式啟用:
1. 加提示 RESULT_CACHE
SQL> SELECT /*+ RESULT_CACHE */ department_id, AVG(salary)
2 FROM hr.employees
3 GROUP BY department_id;
12 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 1192169904
--------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 11 | 77 | 4 (25)| 00:00:01 |
| 1 | RESULT CACHE | 3w0d0687vphfr3gvhgbcpfg89s | | | | |
| 2 | HASH GROUP BY | | 11 | 77 | 4 (25)| 00:00:01 |
| 3 | TABLE ACCESS FULL| EMPLOYEES | 107 | 749 | 3 (0)| 00:00:01 |
--------------------------------------------------------------------------------------------------
Result Cache Information (identified by operation id):
------------------------------------------------------
1 - column-count=2; dependencies=(HR.EMPLOYEES); name="SELECT /*+ RESULT_CACHE */ department_id, AVG(salary)
FROM hr.employees
GROUP BY department_id"
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
0 consistent gets
0 physical reads
0 redo size
853 bytes sent via SQL*Net to client
523 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
12 rows processed
修改查詢中涉及到的表的result_cache屬性為force:
SQL> ALTER TABLE hr.employees RESULT_CACHE (MODE FORCE);
Table altered.
SQL> SELECT department_id, AVG(salary)
2 FROM hr.employees
3 GROUP BY department_id;
12 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 1192169904
--------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 11 | 77 | 4 (25)| 00:00:01 |
| 1 | RESULT CACHE | 3w0d0687vphfr3gvhgbcpfg89s | | | | |
| 2 | HASH GROUP BY | | 11 | 77 | 4 (25)| 00:00:01 |
| 3 | TABLE ACCESS FULL| EMPLOYEES | 107 | 749 | 3 (0)| 00:00:01 |
--------------------------------------------------------------------------------------------------
Result Cache Information (identified by operation id):
------------------------------------------------------
1 - column-count=2; dependencies=(HR.EMPLOYEES); name="SELECT department_id, AVG(salary)
FROM hr.employees
GROUP BY department_id"
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
0 consistent gets
0 physical reads
0 redo size
853 bytes sent via SQL*Net to client
523 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
12 rows processed
清除result cache中的快取資料:
SQL> exec DBMS_RESULT_CACHE.FLUSH
PL/SQL procedure successfully completed.
檢視result cache的使用情況:
SQL> set serveroutput on
SQL> EXECUTE 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 = 1376K bytes (1376 blocks)
Maximum Result Size = 68K bytes (68 blocks)
[Memory]
Total Memory = 167864 bytes [0.121% of the Shared Pool]
... Fixed Memory = 10696 bytes [0.008% of the Shared Pool]
... Dynamic Memory = 157168 bytes [0.114% of the Shared Pool]
....... verhead = 124400 bytes
....... Cache Memory = 32K bytes (32 blocks)
........... Unused Memory = 30 blocks
........... Used Memory = 2 blocks
............... Dependencies = 1 blocks (1 count)
............... Results = 1 blocks
................... SQL = 1 blocks (1 count)
PL/SQL procedure successfully completed.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10972173/viewspace-748860/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle 11g新特性:Result CacheOracle
- 11G result cache新特性的更多深入研究
- SQL Query Result Cache的使用和配置--Oracle 11G新特性SQLOracle
- 11G result cache新特性的一些發現和個人見解
- 【ORACLE新特性】11G 分割槽新特性Oracle
- Oracle11g新特性:SQL Result Cache [zt]OracleSQL
- Oracle 11g 新特性Oracle
- 【11gR2新特性】result cache 的三種模式模式
- 11g data guard 新特性
- 11g新特性--active dataguard
- oracle 11g 的新特性Oracle
- 11G新特性:FLASHBACK ARCHIVEHive
- 11g新特性:Pending Statistics
- Oracle 11g 新特性簡介Oracle
- Oracle 11g 新特性之DRCPOracle
- 11g 新特性—— Active Database DuplicationDatabase
- Oracle 11g 新特性(轉載)Oracle
- 11G新特性:FLASHBACK ARCHIVE - 01Hive
- 11G新特性:FLASHBACK ARCHIVE – 02Hive
- Oracle 11g新特性之SecureFilesOracle
- 11g新特性:不可視索引索引
- 11g新特性--pending statistics
- query result cache in oracle 11gOracle
- oracle DG 11g新特性彙總Oracle
- ORACLE 11G新特性之列新增操作Oracle
- 【11g新特性】(I/O calibration)
- Oracle 11g 新特性 -- SecureFiles 說明Oracle
- 11g新特性--invisible indexIndex
- oracle 11g 新特性 表壓縮Oracle
- 【DataGuard】11g 新特性:Active Data Guard
- oracle 11g result_cache分析Oracle
- 12c 新特性之大表自動快取 Automatic Big Table Caching快取
- Oracle 11g 新特性 -- SQL Plan Management 示例OracleSQL
- 11g叢集新特性-scan機制
- 11g新特性--自動儲存管理
- 11G 新特性:密碼大小寫策略密碼
- 11g 新特性—— Active Database Duplication for A standby databaseDatabase
- 天天學習ORACLE(三)-11G新特性Oracle