关于参数db_file_multiblock_read_count与_db_file_optimizer_read_count

db_file_multiblock_read_count争对于oracle的全表扫描或者快速全索引扫描一次读取最大的BLOCK数。

DB_FILE_MULTIBLOCK_READ_COUNT is one of the parameters you can use to minimizeI/O during table scans. It specifies the maximum number of blocks read in one I/Ooperation during asequential scan. The total number of I/Os needed to perform a fulltable scan depends on such factors as the size of the table, the multiblock read count,and whether parallel execution is being utilized for the operation.

以上摘自oracle-reference,如需要更深的理解请自己参阅。以上红字部分,让我对oracle等待事件db file sequential read与db file scattered read产生了混淆。

SQL> alter system set db_file_multiblock_read_count = 65;
 
System altered

查询数据库中等待事件

SQL> select event,p3 from v$session_wait a where event like  'db file%read';
 
EVENT                                                                    P3
---------------------------------------------------------------- ----------

db file scattered read       65

这个p3值代表块数,V$session_wait里的p3text里有定义,或者参看V$event_name视图,此处P3值会小于等于65(跳过段头,或者跳过已缓存块,或者跨区)

对于db file sequentialread的P3数值我还没有见过大于1的(单块读,索引上的等待),所以再次提醒自己。区分开这两个等待事件。

 

关于db_file_multiblock_read_count合理数值的确认

declare
v_count      number;
v_last_time  number;
v_exec_time  number;
v_start_time number;
v_end_time   number;


begin
    
  
  for v_db_mbrc in 1 ..128 loop
    
    --execute immediate 'alter system flush buffer_cache'; --正常情况不要在生产库执行该动作

    execute immediate 'alter session set db_file_multiblock_read_count = '||v_db_mbrc;
    v_start_time := dbms_utility.get_time();
    select /*+full(a)+*/ count(1) into v_count from zdadmin.tb_waybill a;
    v_end_time := dbms_utility.get_time();
    v_exec_time  := round((v_end_time - v_start_time));
    
    dbms_output.put_line(
    '一次读取'||to_char(v_db_mbrc,'999')||'块,读取了'||v_count||'行,执行时间'||v_exec_time||',上次时间'||v_last_time);
    
    --dbms_output.put_line(
    --'一次读取'||to_char(v_db_mbrc,'999')||'块,读取了'||v_count||'行,执行时间'||v_exec_time||',原始时间'||v_para_time||','||to_char(round((v_para_time-v_exec_time)/v_exec_time,3)*100,'990.999')||'%。');
    
    v_last_time := v_exec_time;
  end loop;


end;

 

 

_db_file_optimizer_read_count这个隐藏参数oracle-reference里并没有给出,参数值随着更改 db_file_multiblock_read_count 变化而变化

select a.ksppinm name,
       b.ksppstvl value,
       b.ksppstdf isdefault,
       decode(bitand(b.ksppstvf, 7),
              1,
              'MODIFIED',
              4,
              'SYSTEM_MOD',
              'FALSE') ismod,
       decode(bitand(b.ksppstvf, 2), 2, 'TRUE', 'FALSE') isadj
  from sys.x$ksppi a, sys.x$ksppcv b
 where a.inst_id = userenv('Instance')
   and b.inst_id = userenv('Instance')
   and a.indx = b.indx
   and a.ksppinm like '\_db_file_optimizer_read_count%'escape'\';

但这个隐藏参数对cost的计算是有影响的,具体参阅以下链接:

http://www.dbsnake.net/cpu-cost-model-and-tsc.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值