single block read

db file sequential read: 单个块读到SGA buffer中
db file scattered read:多个块读到不连续的SGA buffer中
direct read:单个或者多个块读到PGA中,绕开SGA

一个连续读是单块读。如果db_block_size是8k,那么就是读8K的内容。一个单块读只要由
一个磁盘服务就可以了,不需要所有的磁盘来服务。
如果有高并发的时候,不同的单块请求发布到不同的磁盘上。

环境:
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE    11.2.0.2.0      Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production

Oracle数据库的ASM开启了Direct IO和asynch IO。这样重复执行而不受file system buffer
的影响。

ASM/ASMLib本身支持Direct IO。

SQL> show parameter disk

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
asm_diskgroups                       string
asm_diskstring                       string
disk_asynch_io                       boolean     TRUE

创建表test,每条记录占用一个block,1,000,000 rows。

drop table test purge;

create table test (tid number, tcode varchar2(40), name char(2000), name1 char(2000), name2 char(2000), name3 char(1000)) nologging;

insert /*+ append */ into test select rownum, to_char(rownum), to_char(rownum), to_char(rownum), to_char(rownum), to_char(rownum)
from dba_objects a, dba_objects b where rownum < 4000000;

commit;

create index test_ix on test (tid) nologging;

exec DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=> USER, TABNAME =>'TEST', CASCADE => TRUE,estimate_percent=>20);

创建存储过程,循环执行查询,每个循环执行十次,分别根据tid查询
1, 1001, 2001, ..., 9001
2, 1002, 2002, ..., 9002
...
1000, 2000, 3000, ..., 10000
这样每个查询只查一条记录,也就是一个block,执行的是db file sequential read。

create or replace procedure iotest1(p_start in number, p_length number)
is
 l_num1     number;
 l_num2     number;
 l_num3     number;
 l_num4     number;
 l_num5     number;
 l_num6     number;
 l_num7     number;
 l_num8     number;
 l_num9     number;
 l_num10    number;
    l_name    test.name%TYPE;
begin
 l_num1 := (p_start - 1) * p_length * 10 + 1;
 l_num2 := l_num1 + p_length;
 l_num3 := l_num2 + p_length;
 l_num4 := l_num3 + p_length;
 l_num5 := l_num4 + p_length;
 l_num6 := l_num5 + p_length;
 l_num7 := l_num6 + p_length;
 l_num8 := l_num7 + p_length;
 l_num9 := l_num8 + p_length;
 l_num10 := l_num9 + p_length;
 for i in 1..p_length loop
  begin
    select name into l_name from test where tid = l_num1;
  exception
    when others then
       null;
  end;
  begin
    select name into l_name from test where tid = l_num2;
  exception
    when others then
       null;
  end;
  begin
    select name into l_name from test where tid = l_num3;
  exception
    when others then
       null;
  end;
  begin
    select name into l_name from test where tid = l_num4;
  exception
    when others then
       null;
  end;
  begin
    select name into l_name from test where tid = l_num5;
  exception
    when others then
       null;
  end;
  begin
    select name into l_name from test where tid = l_num6;
  exception
    when others then
       null;
  end;
  begin
    select name into l_name from test where tid = l_num7;
  exception
    when others then
       null;
  end;
  begin
    select name into l_name from test where tid = l_num8;
  exception
    when others then
       null;
  end;
  begin
    select name into l_name from test where tid = l_num9;
  exception
    when others then
       null;
  end;
  begin
    select name into l_name from test where tid = l_num10;
  exception
    when others then
       null;
  end;
  l_num1 := l_num1 + 1;
  l_num2 := l_num2 + 1;
  l_num3 := l_num3 + 1;
  l_num4 := l_num4 + 1;
  l_num5 := l_num5 + 1;
  l_num6 := l_num6 + 1;
  l_num7 := l_num7 + 1;
  l_num8 := l_num8 + 1;
  l_num9 := l_num9 + 1;
  l_num10 := l_num10 + 1;
 end loop;
end;
/


SQL script. 文件iotest.sql:

spool "log/&1.log"
set timing on
set echo on

rem SET AUTOT TRACE

rem alter session set events '10046 trace name context forever, level 12';

exec iotest1(&1, &2);

select 1 from dual;

spool off


shell脚本启动并发数执行脚本iotest1.

#!/bin/bash
n=1
while (( $n <= 4 ))
do
 sqlplus "soe/soe@pft11g" @iotest.sql $n 10000 &
 n=$(( n+1 )) 
done


执行脚本,执行前先清楚buffer_cache, 这样数据总是从disk中读取。
./test.sh

alter system flush buffer_cache;

10046 trace文件:

PARSING IN CURSOR #182928975496 len=38 dep=1 uid=91 ct=3 lid=91 tim=1310448537343524 hv=2604437590 ad='cad77988' sqlid='b986t72dmt42q'
SELECT NAME FROM TEST WHERE TID = :B1
END OF STMT
PARSE #182928975496:c=0,e=110,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=1,plh=1408842701,tim=1310448537343523
BINDS #182928975496:
 Bind#0
  acdty=02 mxl=22(21) mxlc=00 mal=00 scl=00 pre=00
  acflg=13 fl2=206001 frm=00 csi=00 siz=24 ff=0
  kxsbbbfp=2a97610130  bln=22  avl=02  flg=09
  value=1
EXEC #182928975496:c=0,e=203,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=1,plh=1408842701,tim=1310448537343818
WAIT #182928975496: nam='Disk file operations I/O' ela= 8 FileOperation=2 fileno=5 filetype=2 obj#=78157 tim=1310448537343975
WAIT #182928975496: nam='db file sequential read' ela= 5591 file#=5 block#=1001732 blocks=1 obj#=78157 tim=1310448537349665
WAIT #182928975496: nam='db file sequential read' ela= 5760 file#=5 block#=1002416 blocks=1 obj#=78157 tim=1310448537355626
WAIT #182928975496: nam='db file sequential read' ela= 117 file#=5 block#=1001733 blocks=1 obj#=78157 tim=1310448537355871
WAIT #182928975496: nam='db file sequential read' ela= 4430 file#=5 block#=132 blocks=1 obj#=78156 tim=1310448537360495

...

PARSING IN CURSOR #182928973440 len=38 dep=1 uid=91 ct=3 lid=91 tim=1310448537360960 hv=2604437590 ad='cad77988' sqlid='b986t72dmt42q'
SELECT NAME FROM TEST WHERE TID = :B1
END OF STMT
PARSE #182928973440:c=0,e=47,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=1,plh=1408842701,tim=1310448537360958
BINDS #182928973440:
 Bind#0
  acdty=02 mxl=22(21) mxlc=00 mal=00 scl=00 pre=00
  acflg=13 fl2=206001 frm=00 csi=00 siz=24 ff=0
  kxsbbbfp=2a97610160  bln=22  avl=04  flg=09
  value=10001
EXEC #182928973440:c=0,e=139,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=1,plh=1408842701,tim=1310448537361178
WAIT #182928973440: nam='db file sequential read' ela= 151 file#=5 block#=1001753 blocks=1 obj#=78157 tim=1310448537361438
WAIT #182928973440: nam='db file sequential read' ela= 2646 file#=5 block#=10265 blocks=1 obj#=78156 tim=1310448537364254

...

PARSING IN CURSOR #182928943368 len=38 dep=1 uid=91 ct=3 lid=91 tim=1310448537413503 hv=2604437590 ad='cad77988' sqlid='b986t72dmt42q'
SELECT NAME FROM TEST WHERE TID = :B1
END OF STMT
PARSE #182928943368:c=0,e=41,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=1,plh=1408842701,tim=1310448537413502
BINDS #182928943368:
 Bind#0
  acdty=02 mxl=22(21) mxlc=00 mal=00 scl=00 pre=00
  acflg=13 fl2=206001 frm=00 csi=00 siz=24 ff=0
  kxsbbbfp=2a976102e0  bln=22  avl=04  flg=09
  value=90001

...

 Bind#0
  acdty=02 mxl=22(21) mxlc=00 mal=00 scl=00 pre=00
  acflg=13 fl2=206001 frm=00 csi=00 siz=24 ff=0
  kxsbbbfp=2a97610130  bln=22  avl=02  flg=09
  value=10000
EXEC #182928975496:c=0,e=91,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=1,plh=1408842701,tim=1310448606608220
WAIT #182928975496: nam='db file sequential read' ela= 330 file#=5 block#=10264 blocks=1 obj#=78156 tim=1310448606608619
FETCH #182928975496:c=0,e=414,p=1,cr=4,cu=0,mis=0,r=1,dep=1,og=1,plh=1408842701,tim=1310448606608666

...

BINDS #182928943368:
 Bind#0
  acdty=02 mxl=22(21) mxlc=00 mal=00 scl=00 pre=00
  acflg=13 fl2=206001 frm=00 csi=00 siz=24 ff=0
  kxsbbbfp=2a976102e0  bln=22  avl=02  flg=09
  value=100000
EXEC #182928943368:c=0,e=91,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=1,plh=1408842701,tim=1310448606612785
WAIT #182928943368: nam='db file sequential read' ela= 130 file#=5 block#=100618 blocks=1 obj#=78156 tim=1310448606612982
FETCH #182928943368:c=0,e=212,p=1,cr=4,cu=0,mis=0,r=1,dep=1,og=1,plh=1408842701,tim=1310448606613028
CLOSE #182928943368:c=0,e=1,dep=1,type=3,tim=1310448606613073

格式化10046 trace文件,等待事件都是db file sequential read:

tkprof pft11g_ora_21499.trc aa.txt

SQL ID: b986t72dmt42q Plan Hash: 1408842701

SELECT NAME
FROM
 TEST WHERE TID = :B1


call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse       10      0.00       0.00          0          0          0           0
Execute 100000      9.27       9.64          0          0          0           0
Fetch   100000     13.73      46.64     100224     400222          0      100000
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total   200010     23.01      56.28     100224     400222          0      100000

Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 91     (recursive depth: 1)
Number of plan statistics captured: 10

Rows (1st) Rows (avg) Rows (max)  Row Source Operation
---------- ---------- ----------  ---------------------------------------------------
         1          1          1  TABLE ACCESS BY INDEX ROWID TEST (cr=4 pr=2 pw=0 time=6983 us cost=5 size=2006 card=1)
         1          1          1   INDEX RANGE SCAN TEST_IX (cr=3 pr=1 pw=0 time=2653 us cost=3 size=0 card=1)(object id 78157)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  Disk file operations I/O                        1        0.00          0.00
  db file sequential read                    100224        0.19         36.28

/***************************************************************************************/
一个session运行前后视图v$sysstat的数据:

运行前的:
SQL> select * from v$sysstat where name like '%physical%read%' and statistic# = 46;
 
STATISTIC# NAME                                                                  CLASS      VALUE    STAT_ID
---------- ---------------------------------------------------------------- ---------- ---------- ----------
        46 physical read total IO requests                                           8    4806187 3343375620
 
运行后的:
SQL> select * from v$sysstat where name like '%physical%read%' and statistic# = 46;
 
STATISTIC# NAME                                                                  CLASS      VALUE    STAT_ID
---------- ---------------------------------------------------------------- ---------- ---------- ----------
        46 physical read total IO requests                                           8    4907177 3343375620

这段时间内的single block reads的次数,这和10046中的100,224接近:
4,907,177 - 4,806,187 = 100,990

iostat的输出结果:

Device:    rrqm/s wrqm/s   r/s   w/s  rsec/s  wsec/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await  svctm  %util
sda          0.00   2.42 577.98  2.02 9247.68   35.56  4623.84    17.78    16.01     0.24    0.42   0.36  20.83
sda1         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sda2         0.00   0.40  0.00  0.40    0.00    6.46     0.00     3.23    16.00     0.00    6.00   6.00   0.24
sda3         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sda4         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sda5         0.00   0.00 577.98  0.00 9247.68    0.00  4623.84     0.00    16.00     0.21    0.36   0.36  20.59
sda6         0.00   0.00  0.00  0.20    0.00    1.62     0.00     0.81     8.00     0.00   10.00  10.00   0.20
sda7         0.00   2.02  0.00  1.41    0.00   27.47     0.00    13.74    19.43     0.03   23.29   4.86   0.69
sdb          0.00   2.02 572.53  1.41 9163.64   32.32  4581.82    16.16    16.02     0.11    0.19   0.18  10.26
sdb1         0.00   0.00 572.53  0.40 9163.64    8.08  4581.82     4.04    16.01     0.10    0.18   0.17   9.92
sdb2         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sdb3         0.00   2.02  0.00  1.01    0.00   24.24     0.00    12.12    24.00     0.01    6.20   6.20   0.63
sdc          0.00   0.61 585.66  1.41 9373.74   29.09  4686.87    14.55    16.02     0.13    0.23   0.20  11.64
sdc1         0.00   0.00 585.66  0.40 9373.74   12.93  4686.87     6.46    16.02     0.12    0.20   0.20  11.62
sdc2         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sdc3         0.00   0.61  0.00  1.01    0.00   16.16     0.00     8.08    16.00     0.02   16.20   8.60   0.87
sdd          0.00   0.00 588.28  0.61 9425.45   19.39  4712.73     9.70    16.04     0.23    0.40   0.39  23.09
sdd1         0.00   0.00 588.28  0.61 9425.45   19.39  4712.73     9.70    16.04     0.23    0.40   0.39  23.09
sdd2         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sdd3         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sdd4         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00

利用率是20%,响应时间也是小于10ms。IOPS每个达到570。

/***************************************************************************************/
同时运行四个session运行前后的数据:

修改iotest.sh文件
#!/bin/bash
n=1
while (( $n <= 4 ))
do
        sqlplus "soe/soe@pft11g" @iotest.sql $n 10000 &
        n=$(( n+1 ))
done

SQL> select * from v$sysstat where name like '%physical%read%' and statistic# = 46;
 
STATISTIC# NAME                                                                  CLASS      VALUE    STAT_ID
---------- ---------------------------------------------------------------- ---------- ---------- ----------
        46 physical read total IO requests                                           8    5009175 3343375620
 
SQL> select * from v$sysstat where name like '%physical%read%' and statistic# = 46;
 
STATISTIC# NAME                                                                  CLASS      VALUE    STAT_ID
---------- ---------------------------------------------------------------- ---------- ---------- ----------
        46 physical read total IO requests                                           8    5413281 3343375620

5,413,281 - 5,009,175 = 404,106

iostat的输出结果:

Device:    rrqm/s wrqm/s   r/s   w/s  rsec/s  wsec/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await  svctm  %util
sda          1.41   4.22 101.20  1.41 1632.13   44.98   816.06    22.49    16.34     0.91    8.88   5.81  59.66
sda1         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sda2         0.00   2.01  0.00  0.40    0.00   19.28     0.00     9.64    48.00     0.01   17.00  17.00   0.68
sda3         1.41   0.00  0.20  0.00   12.85    0.00     6.43     0.00    64.00     0.00    5.00   5.00   0.10
sda4         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sda5         0.00   0.00 101.00  0.00 1619.28    0.00   809.64     0.00    16.03     0.88    8.70   5.84  58.96
sda6         0.00   0.00  0.00  0.40    0.00    3.21     0.00     1.61     8.00     0.01   21.50  21.50   0.86
sda7         0.00   2.21  0.00  0.60    0.00   22.49     0.00    11.24    37.33     0.02   27.33  27.33   1.65
sdb          0.00   2.01 99.40  1.81 1590.36   40.16   795.18    20.08    16.11     1.05   10.44   6.54  66.20
sdb1         0.00   0.00 99.40  0.80 1590.36   16.06   795.18     8.03    16.03     1.04   10.44   6.61  66.20
sdb2         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sdb3         0.00   2.01  0.00  1.00    0.00   24.10     0.00    12.05    24.00     0.01   10.60  10.60   1.06
sdc          0.00   0.60 109.84  1.41 1783.13   27.31   891.57    13.65    16.27     1.43   12.87   6.94  77.25
sdc1         0.00   0.00 109.84  0.40 1783.13   12.85   891.57     6.43    16.29     1.40   12.66   6.97  76.81
sdc2         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sdc3         0.00   0.60  0.00  1.00    0.00   14.46     0.00     7.23    14.40     0.04   35.80  22.00   2.21
sdd          0.00   0.00 97.79  0.80 1577.51   25.70   788.76    12.85    16.26     0.65    6.54   4.97  49.04
sdd1         0.00   0.00 97.79  0.80 1577.51   25.70   788.76    12.85    16.26     0.64    6.54   4.97  49.00
sdd2         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sdd3         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sdd4         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00

利用率是60%,响应时间小于30ms。IOPS每个磁盘是100左右。

运行时间为16m27s左右,

404,106 / (16 m * 60 s + 27 s) = 404,106 / (987s) = 409 iops。这和iostat的结果接近(100*4 = 400)。


/***************************************************************************************/
同时运行八个session运行前后的数据:

修改iotest.sh文件
#!/bin/bash
n=1
while (( $n <= 8 ))
do
        sqlplus "soe/soe@pft11g" @iotest.sql $n 10000 &
        n=$(( n+1 ))
done

SQL> select * from v$sysstat where name like '%physical%read%' and statistic# = 46;
 
STATISTIC# NAME                                                                  CLASS      VALUE    STAT_ID
---------- ---------------------------------------------------------------- ---------- ---------- ----------
        46 physical read total IO requests                                           8    5414157 3343375620
 
SQL> select * from v$sysstat where name like '%physical%read%' and statistic# = 46;
 
STATISTIC# NAME                                                                  CLASS      VALUE    STAT_ID
---------- ---------------------------------------------------------------- ---------- ---------- ----------
        46 physical read total IO requests                                           8    6221660 3343375620

6,221,660 - 5,414,157 = 807,503

Device:    rrqm/s wrqm/s   r/s   w/s  rsec/s  wsec/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await  svctm  %util
sda          1.40   8.22 169.14 14.43 2725.45  181.16  1362.73    90.58    15.83     6.42   34.89   5.17  94.91
sda1         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sda2         0.00   7.01  0.00  9.02    0.00  128.26     0.00    64.13    14.22     1.23  136.07   7.87   7.09
sda3         1.40   0.00  0.20  0.00   12.83    0.00     6.41     0.00    64.00     0.00   24.00  24.00   0.48
sda4         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sda5         0.00   0.00 168.94  0.00 2712.63    0.00  1356.31     0.00    16.06     2.90   17.09   5.56  93.85
sda6         0.00   0.00  0.00  0.20    0.00    1.60     0.00     0.80     8.00     0.00   12.00  12.00   0.24
sda7         0.00   1.20  0.00  5.21    0.00   51.30     0.00    25.65     9.85     2.28  437.88  29.08  15.15
sdb          0.00   3.81 163.33  2.20 2610.02   52.91  1305.01    26.45    16.09     1.52    9.24   4.67  77.31
sdb1         0.00   0.00 163.33  0.40 2610.02    8.02  1305.01     4.01    15.99     1.48    9.05   4.70  76.97
sdb2         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sdb3         0.00   3.81  0.00  1.80    0.00   44.89     0.00    22.44    24.89     0.05   26.67  26.56   4.79
sdc          0.00   3.61 169.14  3.01 2714.23   62.53  1357.11    31.26    16.13     1.75   10.16   4.81  82.85
sdc1         0.00   0.00 168.94  0.40 2712.63   12.83  1356.31     6.41    16.09     1.66    9.79   4.87  82.44
sdc2         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sdc3         0.00   3.61  0.20  2.61    1.60   49.70     0.80    24.85    18.29     0.09   32.64  12.36   3.47
sdd          0.00   0.00 167.13  0.60 2677.35   19.24  1338.68     9.62    16.08     1.86   11.11   4.88  81.88
sdd1         0.00   0.00 167.13  0.60 2677.35   19.24  1338.68     9.62    16.08     1.86   11.11   4.88  81.88
sdd2         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sdd3         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sdd4         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00

利用率是90%,响应时间小于30ms。IOPS每个磁盘是170左右。

运行时间为19m58s左右,

807,503 / (19 m * 60 s + 58 s) = 807,503 / (1,198s) = 674 iops。这和iostat的结果接近(170*4 = 680)。

/***************************************************************************************/
同时运行12个session运行前后的数据:

Device:    rrqm/s wrqm/s   r/s   w/s  rsec/s  wsec/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await  svctm  %util
sda          0.00   0.80 207.04  1.21 3322.33   16.10  1661.17     8.05    16.03     3.26   15.59   4.48  93.26
sda1         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sda2         0.00   0.80  0.00  1.01    0.00   14.49     0.00     7.24    14.40     0.03   31.60  30.00   3.02
sda3         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sda4         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sda5         0.00   0.00 207.04  0.00 3322.33    0.00  1661.17     0.00    16.05     3.22   15.49   4.49  93.00
sda6         0.00   0.00  0.00  0.20    0.00    1.61     0.00     0.80     8.00     0.01   39.00  39.00   0.78
sda7         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sdb          0.00   2.01 225.96  1.61 3621.73   38.63  1810.87    19.32    16.08     2.73   11.99   4.12  93.84
sdb1         0.00   0.00 225.96  0.60 3621.73   14.49  1810.87     7.24    16.05     2.66   11.73   4.14  93.72
sdb2         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sdb3         0.00   2.01  0.00  1.01    0.00   24.14     0.00    12.07    24.00     0.07   70.60  70.60   7.10
sdc          0.00   1.81 218.11  2.82 3486.52   35.41  1743.26    17.71    15.94     2.77   14.00   4.11  90.70
sdc1         0.00   0.00 218.11  0.40 3486.52   12.88  1743.26     6.44    16.01     2.60   12.07   4.14  90.48
sdc2         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sdc3         0.00   1.81  0.00  2.41    0.00   22.54     0.00    11.27     9.33     0.17  188.92  27.00   6.52
sdd          0.00   0.00 223.74  0.80 3586.32   25.75  1793.16    12.88    16.09     3.40   15.15   4.27  95.98
sdd1         0.00   0.00 223.74  0.80 3586.32   25.75  1793.16    12.88    16.09     3.40   15.15   4.27  95.98
sdd2         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sdd3         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sdd4         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00

利用率是90~95%,响应时间小于30ms。IOPS每个磁盘是200左右。

SQL> select * from v$sysstat where name like '%physical%read%' and statistic# = 46;
 
STATISTIC# NAME                                                                  CLASS      VALUE    STAT_ID
---------- ---------------------------------------------------------------- ---------- ---------- ----------
        46 physical read total IO requests                                           8    1750848 3343375620
 
SQL> select * from v$sysstat where name like '%physical%read%' and statistic# = 46;
 
STATISTIC# NAME                                                                  CLASS      VALUE    STAT_ID
---------- ---------------------------------------------------------------- ---------- ---------- ----------
        46 physical read total IO requests                                           8    2958415 3343375620
 
1,750,848 - 2,958,415 = 1,207,567

运行时间为24m02s左右,

1,207,567 / (24 m * 60 s + 2 s) = 1,207,567 / (1,442s) = 837 iops。这和iostat的结果接近(200*4 = 800)。

/***************************************************************************************/
同时运行16个session运行前后的数据:

Device:    rrqm/s wrqm/s   r/s   w/s  rsec/s  wsec/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await  svctm  %util
sda          0.00   6.22 244.98  2.81 3910.04   71.69  1955.02    35.84    16.07     3.68   14.89   3.92  97.05
sda1         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sda2         0.00   4.22  0.00  0.40    0.00   36.95     0.00    18.47    92.00     0.03   63.00  63.00   2.53
sda3         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sda4         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sda5         0.00   0.00 244.98  0.80 3910.04    5.82  1955.02     2.91    15.93     3.51   14.31   3.95  97.05
sda6         0.00   0.00  0.00  0.20    0.00    1.61     0.00     0.80     8.00     0.01   62.00  62.00   1.24
sda7         0.00   2.01  0.00  1.41    0.00   27.31     0.00    13.65    19.43     0.14   97.14  64.57   9.08
sdb          0.00   3.21 247.19  2.21 3980.72   51.41  1990.36    25.70    16.17     4.80   19.21   3.95  98.53
sdb1         0.00   0.00 247.19  0.60 3980.72   14.46  1990.36     7.23    16.12     4.45   17.94   3.97  98.25
sdb2         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sdb3         0.00   3.21  0.00  1.61    0.00   36.95     0.00    18.47    23.00     0.34  216.12 213.00  34.22
sdc          0.00   0.20 238.76  0.40 3852.21   14.46  1926.10     7.23    16.17     5.27   22.06   4.15  99.30
sdc1         0.00   0.00 238.76  0.20 3852.21    6.43  1926.10     3.21    16.15     5.26   22.04   4.15  99.18
sdc2         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sdc3         0.00   0.20  0.00  0.20    0.00    8.03     0.00     4.02    40.00     0.01   43.00  44.00   0.88
sdd          0.00   0.00 241.77  0.60 3871.49   19.28  1935.74     9.64    16.05     2.87   11.81   3.93  95.28
sdd1         0.00   0.00 241.77  0.60 3871.49   19.28  1935.74     9.64    16.05     2.87   11.81   3.93  95.28
sdd2         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sdd3         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00
sdd4         0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00

利用率是95~99%,响应时间小于10~200ms。IOPS每个磁盘是240左右。

SQL> select * from v$sysstat where name like '%physical%read%' and statistic# = 46;
 
STATISTIC# NAME                                                                  CLASS      VALUE    STAT_ID
---------- ---------------------------------------------------------------- ---------- ---------- ----------
        46 physical read total IO requests                                           8    2958647 3343375620
 
SQL> select * from v$sysstat where name like '%physical%read%' and statistic# = 46;
 
STATISTIC# NAME                                                                  CLASS      VALUE    STAT_ID
---------- ---------------------------------------------------------------- ---------- ---------- ----------
        46 physical read total IO requests                                           8    4571005 3343375620

4,571,005 - 2,958,647 = 1,612,358

运行时间为29m38s左右,

1,612,358 / (29 m * 60 s + 38 s) = 1,612,358 / (1,778s) = 906 iops。这和iostat的结果接近(240*4 = 960)。


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25105315/viewspace-702028/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/25105315/viewspace-702028/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在 Android 系统中,可以通过 NFC 技术读写 RFID 标签。在上述代码中,Tag 对象是通过 NFC 技术读取到的 RFID 标签信息获取的。 在 Android 开发中,可以通过注册一个 `BroadcastReceiver` 来监听 NFC 标签的读取事件,当检测到 NFC 标签靠近手机时,系统会发送一个广播,开发者可以通过该广播获取到一个 Tag 对象。具体的代码可以参考以下示例: ```java public class NfcReaderActivity extends AppCompatActivity { private NfcAdapter mNfcAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_nfc_reader); // 获取系统的 NFC 适配器实例 mNfcAdapter = NfcAdapter.getDefaultAdapter(this); } @Override protected void onResume() { super.onResume(); // 创建 PendingIntent 对象,用于处理 NFC 标签的读取事件 PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); IntentFilter[] filters = new IntentFilter[] { new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED) }; // 开始监听 NFC 事件 mNfcAdapter.enableForegroundDispatch(this, pendingIntent, filters, null); } @Override protected void onPause() { super.onPause(); // 停止监听 NFC 事件 mNfcAdapter.disableForegroundDispatch(this); } @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); // 获取当前检测到的 NFC 标签的 Tag 对象 Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); if (tag != null) { // 在这里进行读取标签数据的操作 try { byte[] blockData = readBlock(tag, 1); // 处理读取到的数据 } catch (IOException e) { e.printStackTrace(); } } } public static byte[] readBlock(Tag tag, int blockNumber) throws IOException { // 获取 NfcV 实例 NfcV nfcv = NfcV.get(tag); nfcv.connect(); // 构造读取命令 byte[] readCmd = new byte[] { (byte) 0x20, (byte) 0x20, (byte) blockNumber }; byte[] data = nfcv.transceive(readCmd); // 关闭连接 nfcv.close(); // 处理读取结果 if (data != null && data.length >= 1 && data[0] == 0x00) { byte[] blockData = new byte[4]; System.arraycopy(data, 1, blockData, 0, 4); return blockData; } else { throw new IOException("读取块失败"); } } } ``` 在上面的例子中,`onNewIntent()` 方法会在检测到 NFC 标签靠近手机时被调用,可以通过 `intent.getParcelableExtra(NfcAdapter.EXTRA_TAG)` 获取到当前检测到的 NFC 标签的 Tag 对象。然后,可以调用 `readBlock()` 方法来读取标签数据。注意,在读取标签数据之前,需要先调用 `nfcv.connect()` 方法建立连接,读取数据之后再调用 `nfcv.close()` 方法关闭连接。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值