latch测试

 真的是写了一天的作业。

2.模拟PPT中的例子,做一个绑定变量和非绑定变量的资源消耗对比示例,给出过程和结果。可以使用latch_test.txt文档中提供的脚本。

实验环境:

数据库oracle 11gR2  系统:linux6.2

结果:

Name                             Run1        Run2        Diff

LATCH.corrupted undo seg latch       1,712         160      -1,552

STAT...parse time elapsed            1,775          79      -1,696

STAT...Elapsed Time                  1,845          92      -1,753

STAT...DB time                       1,849          74      -1,775

LATCH.DML lock allocation            1,918         113      -1,805

LATCH.redo allocation                1,929         118      -1,811

STAT...opened cursors cumulati       1,868          15      -1,853

STAT...execute count                 1,870          17      -1,853

STAT...parse count (total)           1,871          17      -1,854

STAT...parse count (hard)            1,859           3      -1,856

STAT...calls to get snapshot s       1,874          14      -1,860

STAT...enqueue releases              1,867           5      -1,862

STAT...enqueue requests              1,868           5      -1,863

LATCH.SQL memory manager worka       2,233         109      -2,124

LATCH.cache buffers lru chain        2,687         229      -2,458

LATCH.object queue header oper       3,007         239      -2,768

LATCH.session allocation             3,867         227      -3,640

LATCH.In memory undo latch           3,926         283      -3,643

LATCH.kks stats                      3,729           5      -3,724

LATCH.enqueues                       4,075           8      -4,067

LATCH.shared pool simulator          4,749          19      -4,730

LATCH.simulator hash latch           5,818         220      -5,598

LATCH.enqueue hash chains            6,059         125      -5,934

LATCH.session idle bit               6,508         284      -6,224

STAT...recursive calls               7,534         118      -7,416

LATCH.row cache objects             34,628       1,046     -33,582

STAT...session uga memory max      123,452      65,512     -57,940

STAT...session uga memory           65,512           0     -65,512

LATCH.shared pool                   85,903         532     -85,371

LATCH.cache buffers chains         101,552       4,652     -96,900 

Run1 latches total versus runs -- difference and pct

Run1        Run2        Diff       Pct

277,204       8,831    -268,373  3,138.99%

 

3.用示例说明表数据中出现热块的场景,并给出解决方案

 

TEST@orcl> create table masicong (id number,name varchar(10));

Table created.
 
 TEST@orcl>insert into masicong values(1,'masicong1');
 
1 row created.
 
TEST@orcl> insert into masicong values(2,'masicong2');
TEST@orcl> commit;
 
Commit complete.
 
TEST@orcl> select dbms_rowid.ROWID_RELATIVE_FNO(rowid) file# from masicong;
 
     FILE#
----------
         4
                  
TEST@orcl> select dbms_rowid.ROWID_RELATIVE_FNO(rowid) file#,dbms_rowid.ROWID_BLOCK_NUMBER(rowid) block# from masicong;
 
     FILE#     BLOCK#
---------- ----------
         4        542
         4        542
 
TEST@orcl> select sid from v$mystat where rownum=1;
 
       SID
----------
        59
 
TEST@orcl> declare
  2     i number:=0;
  3   begin 
  4       loop
  5           update masicong set name='masicong4' where id=2;
  6           i:=i+1;
  7           if mod(i,100)=0 then
  8                commit;
  9        end if;
 10       end loop;
 11   end;
 12   /        
 
 TEST@orcl> select sid from v$mystat where rownum=1;
 
       SID
----------
        30
 declare
   i number:=0;
 begin 
     loop
         update masicong set name='masicong3' where id=1;
         i:=i+1;
         if mod(i,100)=0 then
              commit;
      end if;
     end loop;
 end;
 /       
 
 SYS@orcl> select s.sid,w.event from v$session s,v$session_wait w where s.sid=w.sid and s.status='ACTIVE';
 
       SID EVENT
---------- ----------------------------------------------------------------
         1 latch: session allocation
         2 pmon timer
         3 VKTM Logical Idle Wait
         4 rdbms ipc message
         5 DIAG idle wait
         6 rdbms ipc message
         7 rdbms ipc message
         8 DIAG idle wait
         9 rdbms ipc message
        10 rdbms ipc message
        11 rdbms ipc message
 
       SID EVENT
---------- ----------------------------------------------------------------
        12 rdbms ipc message
        13 smon timer
        14 rdbms ipc message
        15 rdbms ipc message
        16 rdbms ipc message
        20 Streams AQ: qmn coordinator idle wait
        24 rdbms ipc message
        25 Streams AQ: qmn slave idle wait
        27 Streams AQ: waiting for messages in the queue
        29 Streams AQ: waiting for time management or cleanup tasks
        30 buffer busy waits
 
       SID EVENT
---------- ----------------------------------------------------------------
        38 wait for unread message on broadcast channel
        40 SQL*Net message to client
        41 latch: session allocation
        42 Space Manager: slave idle wait
        43 rdbms ipc message
        59 latch: cache buffers chains
 
28 rows selected.
        
SYS@orcl> select sql_text from v$sql t1,v$session t2,v$session_wait t3 
where t1.address=t2.sql_address and t1.hash_value=t2.sql_hash_value
  3  and t2.sid=t3.sid and t3.event='buffer busy waits';
 
SQL_TEXT
---------------------------------------------------
UPDATE MASICONG SET NAME='masicong3' WHERE ID=1

本文出自 “无双城” 博客,谢绝转载!

你可能感兴趣的:(测试)