Home > Database > Mysql Tutorial > Oracle 多 session 串行访问同一个 block 测试

Oracle 多 session 串行访问同一个 block 测试

WBOY
Release: 2016-06-07 17:02:23
Original
815 people have browsed it

一. 相关说明Oracle的数据放在表里面,表的数据表段(segment)里,segment 由extents 组成,extents 由Blocks组成。 每个block

一. 相关说明

Oracle的数据放在表里面,表的数据表段(segment)里,segment 由extents 组成,extents 由Blocks组成。 每个block 可以存放多个row。

OracleSGA里由一个DB buffer 的cache,,该区域由default,keep 和 recycle pool组成。 默认情况下,block 会加载到defaultpool里,Oracle 对数据块的所有操作都在这个pool里进行,包括对数据的修改,修改之后,会有dbwr进行进行写磁盘。

二. 相关测试

2.1 创建一个死循环的存储过程 

CREATE OR REPLACE PROCEDURE SYS.proc_test

AS

str varchar2(100);

i number;

BEGIN

i:=1;

   while(true) loop

     selectobject_name into str from t1 where object_name='RB_TEST';

     if mod(i,1000) =0 then

     DBMS_OUTPUT.put_line(i);

     end if;

     i :=i+1;

end loop;

END ;

/

--这个过程的作用就是循环的去访问一个block

 

2.2 查看这个block的file_id 和 block_id

 

/* Formatted on 2011/7/4 19:45:56(QP5 v5.163.1008.3004) */

SELECT DBMS_ROWID.rowid_relative_fno(ROWID)REL_FNO,

       DBMS_ROWID.rowid_block_number(ROWID)BLOCKNO,

       DBMS_ROWID.rowid_row_number(ROWID) ROWNO

  FROM t1

 WHERE object_name = 'RB_TEST';

 

SYS@anqing2(rac2)> SELECTDBMS_ROWID.rowid_relative_fno (ROWID) REL_FNO,

 2        DBMS_ROWID.rowid_block_number (ROWID) BLOCKNO,

 3        DBMS_ROWID.rowid_row_number (ROWID) ROWNO

 4    FROM t1

 5   WHERE object_name = 'RB_TEST';

 

REL_FNO   BLOCKNO      ROWNO

---------- ---------- ----------

1     294838         54

 

2.3 开启2个session,去调用这个过程,实现不断访问一个block

SYS@anqing2(rac2)> select sid from v$sesstat where rownum=1;

      SID

----------

      147

SYS@anqing1(rac1)> select sid fromv$sesstat where rownum=1;

 

      SID

----------

      141

SYS@anqing2(rac2)> exec proc_test

--持续进行,因为是个死循环---

SYS@anqing1(rac1)> exec proc_test

--持续进行,因为是个死循环---

2.4  查看等待事件

SYS@anqing1(rac1)> select event fromgv$session_wait where sid=147 and inst_id=2;

EVENT

----------------------------------------------------------------

latch: cache bufferschains

SYS@anqing1(rac1)> select event fromgv$session_wait where sid=141 and inst_id=1;

EVENT

----------------------------------------------------------------

latch: cache bufferschains 

linux

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template