|
最初由 玉面飞龙 发布
[B]不知道是什么机制去触发invalid result cache while records being updated
类似mysql的cache result机制 [/B]
不知道跟你说的是不是一回事,我测试了一下:
session 1:
[php]
SQL> exec dbms_result_cache.flush;
PL/SQL procedure successfully completed.
SQL> show parameter result_cache_mode
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
result_cache_mode string FORCE
SQL> select owner,count(*) from t_compress group by owner;
OWNER COUNT(*)
------------------------------ ----------
...
12 rows selected.
[/php]
Session 2:
[php]
SQL> select cache_id,name from v$result_cache_objects;
CACHE_ID NAME
--------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
TEST.T_COMPRESS TEST.T_COMPRESS
5bg7fxv3404w32v0vqv0bhgccf select owner,count(*) from t_compress group by owner
SQL> select * from V$RESULT_CACHE_DEPENDENCY;
RESULT_ID DEPEND_ID OBJECT_NO
---------- ---------- ----------
1 0 58797
--58797为t_compress的object_id.
[/php]
Session 1:
[php]
SQL> set autot trace
SQL> select owner,count(*) from t_compress group by owner;
12 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 2456935480
--------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost
(%CPU)| Time |
--------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 12 | 72 | 79
(8)| 00:00:01 |
| 1 | RESULT CACHE | 5bg7fxv3404w32v0vqv0bhgccf | | |
| |
| 2 | HASH GROUP BY | | 12 | 72 | 79
(8)| 00:00:01 |
| 3 | TABLE ACCESS FULL| T_COMPRESS | 57865 | 339K| 74
(2)| 00:00:01 |
--------------------------------------------------------------------------------
Result Cache Information (identified by operation id):
------------------------------------------------------
1 - column-count=2; dependencies=(TEST.T_COMPRESS); parameters=(nls); name="s
elect owner,count(*) from t_compress group by owner"
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
0 consistent gets
0 physical reads
0 redo size
679 bytes sent via SQL*Net to client
420 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> update t_compress set owner='TEST1' where owner='test';
0 rows updated.
--更新了0行.
SQL> commit;
Commit complete.
[/php]
Sesssion 2:
[php]
SQL> select * from V$RESULT_CACHE_DEPENDENCY;
no rows selected
--对应的依赖删除了,这时再查询不能使用这个result set.
[/php]
Session 1:
[php]
SQL> set autot trace
SQL> select owner,count(*) from t_compress group by owner;
12 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 2456935480
--------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost
(%CPU)| Time |
--------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 12 | 72 | 79
(8)| 00:00:01 |
| 1 | RESULT CACHE | 5bg7fxv3404w32v0vqv0bhgccf | | |
| |
| 2 | HASH GROUP BY | | 12 | 72 | 79
(8)| 00:00:01 |
| 3 | TABLE ACCESS FULL| T_COMPRESS | 57865 | 339K| 74
(2)| 00:00:01 |
--------------------------------------------------------------------------------
Result Cache Information (identified by operation id):
------------------------------------------------------
1 - column-count=2; dependencies=(TEST.T_COMPRESS); parameters=(nls); name="s
elect owner,count(*) from t_compress group by owner"
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
258 consistent gets
0 physical reads
0 redo size
679 bytes sent via SQL*Net to client
420 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
12 rows processed
[/php]
再看看Result Cache Information的内容,猜下选择是适合结果集的步骤:column-count,dependencies,parameters,name
这几个因素影响result set选择.update会删到dependencies里面对应的.
欢迎探讨... |
|