Oracle 12c 监控 Result Cache的使用

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/seagal890/article/details/82917692

Oracle 12c 监控 Result Cache的使用

从下面这个ALTER TABLE说起:

ALTER TABLE sales RESULT_CACHE (MODE FORCE);

这条SQL语句是什么意思?

这里使用 FORCE table annotation 强制数据库在表级别缓存查询结果。

例如:

ALTER TABLE sales RESULT_CACHE (MODE FORCE);

SELECT prod_id, SUM(amount_sold)
  FROM sales 
 GROUP BY prod_id 
HAVING prod_id=136;

SELECT /*+ NO_RESULT_CACHE */ * 
  FROM sales
 ORDER BY time_id DESC;

上面的查询中,第一个SQL查询会缓存查询结果;但是下面的第二个SQL不会使用 Result Cache特性。

Oracle 12c 中与 Server端和Client端监控相关的系统视图、动态性能视图如下:

Views and Tables with Information About the Result Cache

View/Table Description

V$RESULT_CACHE_STATISTICS

Lists various server result cache settings and memory usage statistics.

V$RESULT_CACHE_MEMORY

Lists all the memory blocks in the server result cache and their corresponding statistics.

V$RESULT_CACHE_OBJECTS

Lists all the objects whose results are in the server result cache along with their attributes.

V$RESULT_CACHE_DEPENDENCY

Lists the dependency details between the results in the server result cache and dependencies among these results.

CLIENT_RESULT_CACHE_STATS$

Stores cache settings and memory usage statistics for the client result caches obtained from the OCI client processes. This statistics table contains entries for each client process that uses result caching. After the client processes terminate, the database removes their entries from this table. The client table contains information similar to V$RESULT_CACHE_STATISTICS.

DBA_TABLESUSER_TABLESALL_TABLES

Contains a RESULT_CACHE column that shows the result cache mode annotation for the table. If the table is not annotated, then this column shows DEFAULT. This column applies to both server and client result caches.

COLUMN name FORMAT a20
SELECT name, value
  FROM V$RESULT_CACHE_STATISTICS;
SQL> COLUMN name FORMAT a20
SQL> SELECT name, value
  2    FROM V$RESULT_CACHE_STATISTICS;

NAME                 VALUE
-------------------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------
Block Size (Bytes)   1024
Block Count Maximum  12384
Block Count Current  2528
Result Size Maximum  619
(Blocks)

Create Count Success 19
Create Count Failure 0
Find Count           48
Invalidation Count   2
Delete Count Invalid 0
Delete Count Valid   0
Hash Chain Length    0-1
Find Copy Count      44
Latch (Share)        0

已选择 13 行。

已用时间:  00: 00: 00.11

 Client端监控:

SELECT stat_id, SUBSTR(name,1,20), value, cache_id
  FROM CLIENT_RESULT_CACHE_STATS$
 ORDER BY cache_id, stat_id;

猜你喜欢

转载自blog.csdn.net/seagal890/article/details/82917692