[20190214]11g Query Result Cache RC Latches补充.txt

--//上午测试链接:http://blog.itpub.net/267265/viewspace-2632907/
--//发现自己的一个错误,另外写一篇帖子更正.
--//顺便复习result cache的相关内容:链接:https://blog.csdn.net/jolly10/article/details/81382644

查看SQL结果高速缓存字典信息
(G)V$RESULT_CACHE_STATISTICS : 列出各种高速缓存设置和内存使用量统计信息
(G)V$RESULT_CACHE_MEMORY : 列出所有内存块和相应的统计信息
(G)V$RESULT_CACHE_OBJECTS: 列出所有对象(高速缓存结果和依赖性)及其属性
(G)V$RESULT_CACHE_DEPENDENCY: 列出高速缓存结果之间的依赖性详细信息及依赖性

dbms_result_cache包可以监视和管理result cache

例如:
dbms_result_cache.flush:清除result cache。
dbms_result_cache.invalidate(owner,name):使某对象的result cache无效。
dbms_result_cache.status:显示result cache的状态。
dbms_result_cache.memory_report:显示result cache的内存使用状况。

1.环境:
SCOTT@book> @ ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

SCOTT@book> create table job_times ( sid   number, time_ela number);
Table created.

SCOTT@book> create table hc_t ( n number(*,0), v varchar2(200)) ;
Table created.

SCOTT@book> insert into hc_t select level, dbms_random.string('p', 200) from dual connect by level <= 10000;
10000 rows created.

SCOTT@book> create unique index i_hc_t on hc_t(n);
Index created.

SCOTT@book> commit;
Commit complete.

--//分析表略.

create or replace procedure do_rc(
 p_iterations in number,p_max in number
) is
 l_rowid  rowid;
 l_n number;
begin
 insert into job_times
  values (sys_context('userenv', 'sid'), dbms_utility.get_time)
  returning rowid into l_rowid;

for i in 1 .. p_iterations
 loop
  l_n:=trunc(dbms_random.value(1, p_max));
  for cur in (select /*+ result_cache */ * from hc_t where n=l_n)
  loop
   null;
  end loop;
 end loop;

update job_times set
   time_ela=dbms_utility.get_time-time_ela
  where rowid=l_rowid;
end;
/
--//注:我加入参数p_max,限制取值范围.
--//为了重复测试建立脚本.
$ cat aa.sql
delete from job_times;
Commit ;

declare
 l_job number;
begin
 for i in 1 .. 4
 loop
  dbms_job.submit(
   job => l_job,
   what => 'do_rc(100000,&&1);'
    );
 end loop;
end;
/
commit ;

2.开始测试:
SCOTT@book> 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  1792K
result_cache_mode                    string       MANUAL
result_cache_remote_expiration       integer      0

SCOTT@book> exec dbms_result_cache.flush()
PL/SQL procedure successfully completed.

SCOTT@book> set serverout on
SCOTT@book> 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          = 0 bytes
Maximum Cache Size  = 0 bytes (0 blocks)
Maximum Result Size = 0 bytes (0 blocks)
[Memory]
Total Memory = 40568 bytes [0.022% of the Shared Pool]
... Fixed Memory = 40568 bytes [0.022% of the Shared Pool]
... Dynamic Memory = 0 bytes [0.000% of the Shared Pool]
PL/SQL procedure successfully completed.

--//我前面测试忽略的result cache的大小.

SCOTT@book> @ aa.sql 10000
4 rows deleted.
Commit complete.
PL/SQL procedure successfully completed.
Commit complete.

SCOTT@book> select count(*),avg(TIME_ELA),sum(TIME_ELA) from job_times ;
  COUNT(*) AVG(TIME_ELA) SUM(TIME_ELA)
---------- ------------- -------------
         4        4001.5         16006

--//以上我上午测试的结果.大约每个job需要40秒上下.

SCOTT@book> 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  = 1792K bytes (1792 blocks)
Maximum Result Size = 89K bytes (89 blocks)
[Memory]
Total Memory = 2003960 bytes [1.111% of the Shared Pool]
... Fixed Memory = 40568 bytes [0.022% of the Shared Pool]
... Dynamic Memory = 1963392 bytes [1.089% of the Shared Pool]
....... Overhead = 128384 bytes
....... Cache Memory = 1792K bytes (1792 blocks)
........... Unused Memory = 0 blocks
........... Used Memory = 1792 blocks
............... Dependencies = 1 blocks (1 count)
............... Results = 1791 blocks
................... SQL     = 1791 blocks (1791 count)
PL/SQL procedure successfully completed.

--//实际上我的环境仅仅能容纳1791个结果.也就是我的配置太小,共享池不够大.result_cache_max_result=5,仅仅使用共享池的5%.

SCOTT@book> @ aa.sql 1791
4 rows deleted.
Commit complete.
PL/SQL procedure successfully completed.
Commit complete.

SCOTT@book> select count(*),avg(TIME_ELA),sum(TIME_ELA) from job_times ;
  COUNT(*) AVG(TIME_ELA) SUM(TIME_ELA)
---------- ------------- -------------
         4         440.5          1762

--//你可以发现这个就与没有做result cache的结果相近了.
--//我重启数据库.通过result cache :RC latch记数也可以验证这个问题.

SCOTT@book> column name format a30
SCOTT@book> select name, gets, misses, sleeps, wait_time from v$latch where name like 'Result Cache%';
NAME                                 GETS     MISSES     SLEEPS  WAIT_TIME
------------------------------ ---------- ---------- ---------- ----------
Result Cache: RC Latch                  0          0          0          0
Result Cache: SO Latch                  0          0          0          0
Result Cache: MB Latch                  0          0          0          0

SCOTT@book> @ aa.sql 1791
4 rows deleted.
Commit complete.
PL/SQL procedure successfully completed.
Commit complete.

SCOTT@book> select count(*),avg(TIME_ELA),sum(TIME_ELA) from job_times ;
  COUNT(*) AVG(TIME_ELA) SUM(TIME_ELA)
---------- ------------- -------------
         4           432          1728

SCOTT@book> select name, gets, misses, sleeps, wait_time from v$latch where name like 'Result Cache%';
NAME                                 GETS     MISSES     SLEEPS  WAIT_TIME
------------------------------ ---------- ---------- ---------- ----------
Result Cache: RC Latch             405177       3865         10        132
Result Cache: SO Latch                  8          0          0          0
Result Cache: MB Latch                  0          0          0          0

SCOTT@book> @ aa.sql 10000
4 rows deleted.
Commit complete.
PL/SQL procedure successfully completed.
Commit complete.

SCOTT@book> select count(*),avg(TIME_ELA),sum(TIME_ELA) from job_times ;
  COUNT(*) AVG(TIME_ELA) SUM(TIME_ELA)
---------- ------------- -------------
         4       3978.25         15913

SCOTT@book> select name, gets, misses, sleeps, wait_time from v$latch where name like 'Result Cache%';
NAME                                 GETS     MISSES     SLEEPS  WAIT_TIME
------------------------------ ---------- ---------- ---------- ----------
Result Cache: RC Latch            1787843     534395     683654   67269002
Result Cache: SO Latch                 16          0          0          0
Result Cache: MB Latch                  0          0          0          0

[20190214]11g Query Result Cache RC Latches补充.txt的更多相关文章

  1. [20190214]11g Query Result Cache RC Latches.txt

    [20190214]11g Query Result Cache RC Latches.txt --//昨天我重复链接http://www.pythian.com/blog/oracle-11g-qu ...

  2. oracle 11g 之 result cache

    oracle 11g 之 result cache 今天是2013-10-12,打算最近时间研究一下shared pool的相关原理以及awr报告分析.今天学习一下在oracle 11g shared ...

  3. [20190415]11g下那些latch是共享的.txt

    [20190415]11g下那些latch是共享的.txt http://andreynikolaev.wordpress.com/2010/11/23/shared-latches-by-oracl ...

  4. 11G新特性 -- Result Cache

    共享池存放sql语句的解析和编译版本,以便数据库能快速执行频繁执行的sql语句和plsql. 在11g中,数据库使用result cache来存放sql和plsql的执行结果. result cach ...

  5. orace result cache解析

      (1)   orace 11.2.0.4 在RAC数据库Dataguard切换时,出现少量数据丢失:          解决方案:关闭result cache 功能 或升级数据库版本并安装补丁: ...

  6. GaussDB(for MySQL) :Partial Result Cache,通过缓存中间结果对算子进行加速

    摘要:华为云数据库高级内核技术专家详解GaussDB(for MySQL)Partial Result Cache特性,如何通过缓存中间结果对算子进行加速? 本文分享自华为云社区<GaussDB ...

  7. django+uwsgi+nginx数据表过大引起"out of memory for query result"

    昨天负责的一个项目突然爆“out of memory for query result”. 背景 项目的数据表是保存超过10m的文本数据,通过json方式保存进postgres中,上传一个13m的大文 ...

  8. PL/SQL:these query result are not updateable,include the ROWID to get updateab -----for update

    these query result are not updateable,include the ROWID to get updateab 原因: 其实,选中一个表后,右键,如果选择“query ...

  9. Oralce查询后修改数据,弹窗报提示these query result are not updateable,include the ROWID to get updateable

    select t.*, (select a.ANNEXNAME from base_annex a where a.id = t.closeFile) closeFileName, (select a ...

随机推荐

  1. yum源配置

    我这里使用的centos7操作系统. 下载地址是:https://www.centos.org/download/ yum仓库的创建可以参考: http://www.cnblogs.com/zhaoj ...

  2. 浅谈基于WOPI协议实现跨浏览器的Office在线编辑解决方案

    如今,基于Web版的Office 在线预览与编辑功能已成为一种趋势,而关于该技术的实现却成为了国内大部份公司的技术挑战,挑战主要存在于两方面: 其一:目前国内乃至微软本身,还没有相对较为完善的解决方案 ...

  3. MySQL中间件之ProxySQL(8):SQL语句的重写规则

    返回ProxySQL系列文章:http://www.cnblogs.com/f-ck-need-u/p/7586194.html 1.为什么要重写SQL语句 ProxySQL在收到前端发送来的SQL语 ...

  4. 翻译:如何向MariaDB中快速插入数据(已提交到MariaDB官方手册)

    本文为mariadb官方手册:How to Quickly Insert Data Into MariaDB的译文. 原文:https://mariadb.com/kb/en/how-to-quick ...

  5. 【golang-GUI开发】Qt5的安装

    golang一直被认为没有好的GUI库,事实并非如此. 目前有基于gtk+3.0的gotk3:https://github.com/gotk3/gotk3 以及接下来我们要说的qt:https://g ...

  6. 另类爬虫:从PDF文件中爬取表格数据

    简介   本文将展示一个稍微不一样点的爬虫.   以往我们的爬虫都是从网络上爬取数据,因为网页一般用HTML,CSS,JavaScript代码写成,因此,有大量成熟的技术来爬取网页中的各种数据.这次, ...

  7. TensorFlow.js入门(一)一维向量的学习

    TensorFlow的介绍   TensorFlow是谷歌基于DistBelief进行研发的第二代人工智能学习系统,其命名来源于本身的运行原理.Tensor(张量)意味着N维数组,Flow(流)意味着 ...

  8. [转]使用jenkins实现持续集成

    本文转自:https://www.cnblogs.com/zishengY/p/7170656.html 一.jenkins 介绍 它是一个自动化的周期性的集成测试过程,从检出代码.编译构建.运行测试 ...

  9. spring_01概念及案例

    1.什么是IOC? IOC概念:inverse of Controll,控制反转,所谓控制反转,就是把创建对象和维护对象关系的权利从程序中转移到spring的容器中(applicationContex ...

  10. matlab rank

    k =rank(A)    %a is matrix s = svd(A); tol = max(size(A))*eps(max(s)); r = sum(s > tol);