tft每日頭條

 > 科技

 > 查看表結構細節oracle

查看表結構細節oracle

科技 更新时间:2025-02-12 14:37:38
概述

前面已經用實驗引入了Oracle 11g的Result Cache概念,以及對Oracle 11g的Result Cache的深層原理做了相關介紹,今天主要介紹其中的視圖、工具包、限制條件等。


Result Cache相關視圖

Result Cache功能對應了一些視圖對象,用來輔助觀察Cache中的對象和信息。

SQL> select * from dictionary where table_name like '%RESULT_CACHE%'; --視圖v$result_cache_objects可以查看當前result cache中存在的對象信息。 SQL> select id, type, status, name, cache_id from v$result_cache_objects;

查看表結構細節oracle(一文了解Oracle11g的ResultCache--視圖)1

Oracle為每一個真正存在的Result Cache分配一個Cache ID編号。通過視圖v$result_cache_objects可以監控當前的對象狀态、信息以及依賴關系。

V$result_cache_dependency是描述緩存數據集合和依賴對象關系的視圖。Result Cache中,一個很大的問題就是如何讓緩存及時反饋數據的變化。Oracle采用了對象依賴的機制,一旦對象發生了變化,依賴他的Cache就失效不可用。

SQL> select * from v$result_cache_dependency;

查看表結構細節oracle(一文了解Oracle11g的ResultCache--視圖)2

借助v$result_cache_dependency視圖,我們可以看到對象之間的依賴關系,其中的ID是緩存中的ID編号。

在内存SGA中,Oracle分配對象都是以Chunk為單位進行的。視圖v$result_cache_memory從内存分配角度,看對象信息緩存的情況。

SQL> select * from v$result_cache_memory;

查看表結構細節oracle(一文了解Oracle11g的ResultCache--視圖)3

最後是v$result_cache_statistics,計算統計了數據彙總信息。

SQL> select * from v$result_cache_statistics;

查看表結構細節oracle(一文了解Oracle11g的ResultCache--視圖)4


DBMS_RESULT_CACHE工具包

Oracle為了提供result cache的管理,提供了dbms_result_cache工具包,其中的一些方法,可以幫助我們解決實際中的很多cache問題。

SQL> select dbms_result_cache.Status from dual; --其中清理cache和report cache信息比較有用。 SQL> set serveroutput on size 10000; SQL> exec dbms_result_cache.Memory_Report; --清除result cache SQL> exec dbms_result_cache.Flush; SQL> select id, type, status, name, cache_id from v$result_cache_objects;

查看表結構細節oracle(一文了解Oracle11g的ResultCache--視圖)5


Result Cache的一些限制

首先,臨時表和SYS/system用戶下的數據表是不支持result cache的。

SQL> create table t as select * from dba_objects; SQL> show user; SQL> select /* result_cache*/count(*) from t; SQL> select id, type, status, name, cache_id from v$result_cache_objects; SQL> select /* result_cache*/count(*) from scott.dept; SQL> select id, type, status, name, cache_id from v$result_cache_objects;

查看表結構細節oracle(一文了解Oracle11g的ResultCache--視圖)6

非sys/system對象的數據表才能使用result cache特性。

其次,就是SQL語句中不能包括非确定性的語句和非确定性函數。比如,如果包括sequence對象的nextval和curval,或者sysdate這類的函數,就不能使用result cache。


到這裡關于result cache的内容就介紹完了,後面會分享更多devops和DBA方面的内容,感興趣的朋友可以關注一下~

查看表結構細節oracle(一文了解Oracle11g的ResultCache--視圖)7

,

更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!

查看全部

相关科技资讯推荐

热门科技资讯推荐

网友关注

Copyright 2023-2025 - www.tftnews.com All Rights Reserved