温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Oracle Study之--Oracle等待事件(5)

发布时间:2020-06-20 09:38:12 来源:网络 阅读:430 作者:客居天涯 栏目:关系型数据库

Oracle Study之--Oracle等待事件(5)

 Db file single write
这个等待事件通常只发生在一种情况下,就是Oracle 更新数据文件头信息时(比如发生Checkpoint)。
当这个等待事件很明显时,需要考虑是不是数据库中的数据文件数量太大,导致Oracle 需要花较长的时间来做所有文件头的更新操作(checkpoint)。
这个等待事件有三个参数:
File#: 需要更新的数据块所在的数据文件的文件号。
Block#: 需要更新的数据块号。
Blocks: 需要更新的数据块数目(通常来说应该等于1)。

案例分析:

15:03:26 SYS@ prod>select event,TOTAL_WAITS,AVERAGE_WAIT from v$system_event
15:03:31   2  where upper(event) like 'DB FILE%';
EVENT                                                            TOTAL_WAITS AVERAGE_WAIT
---------------------------------------------------------------- ----------- ------------
db file sequential read                                                 2093          .01
db file scattered read                                                   833          .02
db file single write                                                      27          .28
db file parallel write                                                     5        17.48

15:03:51 SYS@ prod>alter system checkpoint;
System altered.

15:03:35 SYS@ prod>select event,TOTAL_WAITS,AVERAGE_WAIT from v$system_event
  2* where upper(event) like 'DB FILE%'
EVENT                                                            TOTAL_WAITS AVERAGE_WAIT
---------------------------------------------------------------- ----------- ------------
db file sequential read                                                 2673          .01
db file scattered read                                                   833          .02
db file single write                                                      36          .55
db file parallel write                                                     7        14.73
Elapsed: 00:00:00.01

Direct path read
这个等待事件发生在会话将数据块直接读取到PGA当中而不是SGA中的情况,这些被读取的数据通常是这个会话私有的数据,所以不需要放到SGA作为共享数据,因为这样做没有意义。这些数据通常是来自于临时段上的数据,比如一个会话中SQL的排序数据,并行执行过程中间产生的数据,以及Hash Join,merge join产生的排序数据,因为这些数据只对当前的会话的SQL操作有意义,所以不需要放到SGA当中。
当发生direct path read等待事件时,意味着磁盘上有大量的临时数据产生,比如排序,并行执行等操作。或者意味着PGA中空闲空间不足。
这个等待事件有三个参数:
Descriptor address:  一个指针,指向当前会话正在等待的一个direct read I/O。
First dba: descriptor address 中最旧的一个I/O数据块地址。
Block cnt: descriptor address上下文中涉及的有效的buffer 数量。

Oracle Study之--Oracle等待事件(5)
Direct path write
这个等待事件和direct path read 正好相反,是会话将一些数据从PGA中直接写入到磁盘文件上,而不经过SGA。
这种情况通常发生在:
使用临时表空间排序(内存不足)
数据的直接加载(使用append方式加载数据)
并行DML操作。
这个等待事件有三个参数:
Descriptor address: 一个指针,指向当前会话正在等待的一个direct I/O.
First dba: descriptor address 中最旧的一个I/O数据块地址。
Block cnt: descriptor address 上下文中涉及的有效地 buffer 数量。

案例分析:

15:37:17 SCOTT@ prod>
  1* select * from t1 order by 1
600000 rows selected.
Elapsed: 00:00:04.35
Execution Plan
----------------------------------------------------------
Plan hash value: 2148421099
-----------------------------------------------------------------------------------
| Id  | Operation          | Name | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
-----------------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |      |   838K|    10M|       |  4260   (1)| 00:00:52 |
|   1 |  SORT ORDER BY     |      |   838K|    10M|    16M|  4260   (1)| 00:00:52 |
|   2 |   TABLE ACCESS FULL| T1   |   838K|    10M|       |   276   (2)| 00:00:04 |
-----------------------------------------------------------------------------------
Note
-----
   - dynamic sampling used for this statement (level=2)
Statistics
----------------------------------------------------------
          7  recursive calls
          3  db block gets
       1355  consistent gets
       1823  physical reads
          0  redo size
   10809270  bytes sent via SQL*Net to client
     440512  bytes received via SQL*Net from client
      40001  SQL*Net roundtrips to/from client
          0  sorts (memory)
          1  sorts (disk)
     600000  rows processed
     
15:36:39 SYS@ prod>select event,TOTAL_WAITS,AVERAGE_WAIT from v$system_event
  2* where upper(event) like 'DIRECT%'
EVENT                                                            TOTAL_WAITS AVERAGE_WAIT
---------------------------------------------------------------- ----------- ------------
direct path read                                                         154          .03
direct path read temp                                                   1746            0
direct path write temp                                                    63          .98
Elapsed: 00:00:00.04
15:37:31 SYS@ prod>


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI