- 最后登录
- 2015-3-26
- 在线时间
- 21 小时
- 威望
- 29
- 金钱
- 264
- 注册时间
- 2012-6-14
- 阅读权限
- 10
- 帖子
- 27
- 精华
- 0
- 积分
- 29
- UID
- 506
|
9#
发表于 2013-7-14 09:58:19
并不是说sys和system都不行,这个函数缓存我觉得就是有问题
C:\Users\Tom>sqlplus system/oracle@l11g
SQL*Plus: Release 11.2.0.3.0 Production on Sun Jul 14 09:51:36 2013
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning option
SQL> show user
USER is "SYSTEM"
SQL> @c:\a.sql
SQL> SET ARRAYSIZE 2000
SQL>
SQL> show parameter result
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
client_result_cache_lag big integer 3000
client_result_cache_size big integer 0
result_cache_max_result integer 5
result_cache_max_size big integer 2M
result_cache_mode string MANUAL
result_cache_remote_expiration integer 0
SQL> pause
SQL> select dbms_result_cache.status() from dual;
DBMS_RESULT_CACHE.STATUS()
--------------------------------------------------------------------------------------------------------------------------------------
ENABLED
SQL> exec dbms_result_cache.flush;
SQL> pause
SQL> set autot on exp stat
SQL> select /*+ RESULT_CACHE */ department_id, AVG(salary)
2 from hr.employees
3 group by department_id;
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 | 1akffwbzpzduf01pch4018m270 | | | | |
| 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
----------------------------------------------------------
1 recursive calls
0 db block gets
6 consistent gets
6 physical reads
0 redo size
633 bytes sent via SQL*Net to client
359 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
12 rows processed
SQL> set autot off
SQL> pause
SQL> SET SERVEROUTPUT ON
SQL> exec 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 = 2M bytes (2K blocks)
Maximum Result Size = 102K bytes (102 blocks)
[Memory]
Total Memory = 169328 bytes [0.075% of the Shared Pool]
... Fixed Memory = 5352 bytes [0.002% of the Shared Pool]
... Dynamic Memory = 163976 bytes [0.072% of the Shared Pool]
....... Overhead = 131208 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)
SQL> SET SERVEROUTPUT OFF
SQL> pause
SQL> set autot on exp stat
SQL> select /*+ RESULT_CACHE */ department_id, AVG(salary)
2 from hr.employees
3 group by department_id;
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 | 1akffwbzpzduf01pch4018m270 | | | | |
| 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
633 bytes sent via SQL*Net to client
359 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
12 rows processed
SQL> set autot off
SQL> pause
SQL> update hr.employees set salary=salary+10;
SQL> commit;
SQL> pause
SQL> set autot on exp stat
SQL> select /*+ RESULT_CACHE */ department_id, AVG(salary)
2 from hr.employees
3 group by department_id;
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 | 1akffwbzpzduf01pch4018m270 | | | | |
| 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
6 consistent gets
0 physical reads
0 redo size
639 bytes sent via SQL*Net to client
359 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
12 rows processed
SQL> set autot off
SQL> set autot on exp stat
SQL> select /*+ RESULT_CACHE */ department_id, AVG(salary)
2 from hr.employees
3 group by department_id;
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 | 1akffwbzpzduf01pch4018m270 | | | | |
| 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
639 bytes sent via SQL*Net to client
359 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
12 rows processed
SQL> set autot off
SQL> pause |
|