zoukankan      html  css  js  c++  java
  • Select/Update 引起的read by other session

    Select/Update 引起的buffer lock争用于Select/Select 或Update/Update 引起的buffer lock 争用机制有很大差异。
    
    
    Oracle 的Select 操作i奔上一致性读取(cr)为基础,若实际应该读取的数据已修改,则必须读取持有过去映像的CR块。这时若CR块不在当前的高速缓冲区上时,
    
    则应该从磁盘读取撤销块。若多个会话试图读取撤销块时,在将撤销块载入到内存上的过程中发生buffer lock争用。因此Select/Update引起的buffer lock
    
    争用会在如下情况发生:
    
    *特定进程修改特定表,数据的过去映像记录在撤销块。
    
    *很多进程试图同时(或之后)读取已修改的数据。
    
    让我们通过测试对此进行确认,测试方案如下:
    
    
    1)创建拥有5W行的BFW_TEST表
    
    2)一个进程上对BFW_TEST表执行Update,以此创建撤销块。
    
    3)多个进程同时对已修改的数据执行读取(select)操作
    
    4)在此过程中发生buffer lock争用。
    
    
    【测试6】Select/Update 引起的buffer lock争用
    
    --执行select 的procedure
    create or replace procedure  bfw_do_select
    is 
    begin
     for x in (select t1.id as ID1,t2.id as ID2 from bfw_test t1,bfw_test t2 where rownum<=500000) loop
     null;
     end loop;
     end;
    
    ---对相同的表执行Update的Procedure
    create or replace procedure bfw_do_update
    is 
    begin
               update bfw_test set id='';
               end;
    
    
    ---在执行Update期间,多个会话同时执行Select操作。
    
    var job_no number;
    begin
        dbms_job.submit(:job_no,'bfw_do_update;');
        commit;
        for idx in 1 .. 10 loop
          dbms_job.submit(:job_no,'bfw_do_select;');
          end loop;
          commit;
          end;
    
    
    
    1	24-6月 -14 11.24.32.652 上午	6	db file sequential read	3	16295	1	0	0	3	16295
    2	24-6月 -14 11.24.32.652 上午	11	db file sequential read	3	759361	1	0	0	3	759361
    3	24-6月 -14 11.24.32.652 上午	13	read by other session	3	16295	22	0	0	3	16295
    4	24-6月 -14 11.24.32.652 上午	15	read by other session	3	16295	22	0	0	3	16295
    9	24-6月 -14 11.24.32.652 上午	1147	read by other session	3	16295	22	0	0	3	16295
    10	24-6月 -14 11.24.32.652 上午	1149	read by other session	3	16295	22	0	0	3	16295
    11	24-6月 -14 11.24.32.652 上午	1151	read by other session	3	16295	22	0	0	3	16295
    12	24-6月 -14 11.24.32.652 上午	1713	read by other session	3	16295	22	0	0	3	16295
    14	24-6月 -14 11.24.32.652 上午	1718	read by other session	3	16295	22	0	0	3	16295
    15	24-6月 -14 11.24.32.652 上午	1720	read by other session	3	16295	22	0	0	3	16295
    16	24-6月 -14 11.24.31.642 上午	6	read by other session	3	16705	22	0	0	3	16705
    
    查看访问的对象:
    SQL>  select owner,segment_name,segment_type from dba_extents
     where file_id=3 and 16295 between block_id and block_id + blocks-1;  2  
    
    OWNER	   SEGMENT_NAME 								     SEGMENT_TYPE
    ---------- --------------------------------------------------------------------------------- ------------------
    SYS	   _SYSSMU3_4004931649$ 							     TYPE2 UNDO
    
    
    

  • 相关阅读:
    poj_1236 强连通分支
    【winform程序】自定义webrowser控件调用IE的版本
    【小程序开发】微信小程序开发中遇到的那些坑...
    【C#多线程】C#多线程 Thread 开发基础
    【管理心得】不懂带人,你就自己干到死
    【80端口占用】win7下80端口被(Pid=4)占用的解决方法
    【顽固BUG】Visual Studio 2015 + TestDriven.NET-3.8.2860_Personal_Beta 调用的目标发生了异常。
    【HPP开发】让所有中小企业拥有自己的APP
    【创业积累】如何快速开发出一个高质量的APP
    【架构师之路】依赖注入原理---IoC框架
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13352249.html
Copyright © 2011-2022 走看看