今天我要做一个SQL调优,监控该SQL, 利用ASH 监控 该SQL是在sid=4848 上面跑的
db file sequential read等待事件有3个参数:file#,first block#,和block数量。
这个等待事件有3个参数P1,P2,P3,其中P1代表Oracle要读取的文件的绝对文件号,P2代表Oracle从这个文件中开始读取的起始数据块号,P3代表读取的BLOCK数量,通常这个值为1,表明是道单个BLOCK被读取。 SQL> select SESSION_ID,NAME,P1,P2,P3,WAIT_TIME,CURRENT_OBJ#,CURRENT_FILE#,CURRENT_BLOCK#
2 from v$active_session_history ash, v$event_name enm
3 where ash.event#=enm.event#
4 and SESSION_ID=4848; SESSION_ID NAME P1 P2 P3 WAIT_TIME CURRENT_OBJ# CURRENT_FILE# CURRENT_BLOCK#
---------- ------------------------------ ---------- ---------- ---------- ---------- ------------ ------------- --------------
4848 db file sequential read 87 409499 1 0 58744541 87 409499
4848 db file sequential read 674 178953 1 0 58744541 674 178953
4848 db file sequential read 409 491921 1 0 58744541 409 491921
4848 db file sequential read 169 310289 1 0 58744541 169 310289
4848 db file sequential read 21 811534 1 0 58744541 21 811534
4848 db file sequential read 12 494321 1 0 58744541 12 494321
4848 db file sequential read 571 359814 1 0 58744541 571 359814
4848 db file sequential read 18 782340 1 0 58744541 18 782340
4848 db file sequential read 87 409073 1 0 58744541 87 409073
4848 db file sequential read 107 362350 1 0 58744545 107 362350
4848 db file sequential read 674 179953 1 0 58744545 674 179953
4848 db file sequential read 14 562832 1 0 58744545 14 562832
4848 db file sequential read 674 170372 1 0 58744545 674 170372
4848 db file sequential read 15 434867 1 0 58744545 15 434867
4848 db file sequential read 674 180111 1 0 58744545 674 180111
4848 db file sequential read 258 336128 1 0 58744545 258 336128
4848 gc cr grant 2-way 206 1696993 1 0 58744545 206 1696993
4848 gc cr grant 2-way 87 412582 1 0 58744545 87 412582
4848 db file sequential read 15 434831 1 0 58744545 15 434831
4848 db file sequential read 677 175793 1 0 58744545 677 175793
4848 db file sequential read 571 360776 1 0 58744545 571 360776
4848 db file sequential read 250 115741 1 0 58988767 250 115741
4848 db file sequential read 247 337993 1 0 58744545 247 337993
4848 db file sequential read 169 315606 1 0 58744549 169 315606
4848 db file sequential read 246 411238 1 0 58744549 246 411238
4848 db file sequential read 258 341515 1 0 58744549 258 341515
4848 db file sequential read 258 341748 1 0 58744549 258 341748
4848 db file sequential read 17 409377 1 0 58744549 17 409377
4848 db file sequential read 674 171523 1 0 58744549 674 171523
4848 db file sequential read 409 788005 1 0 58744549 409 788005 发现很多都是 db file sequential read等待事件 SQL> select owner,object_name,object_type from dba_objects where object_id=58744549; OWNER OBJECT_NAME OBJECT_TYPE
-------------------- ---------------------------------------- ------------------------------
ADWU SHPMT_GDF_HIST_FCT_NEW TABLE SUBPARTITION SQL> select owner,object_name,object_type from dba_objects where object_id=58744541; OWNER OBJECT_NAME OBJECT_TYPE
-------------------- ---------------------------------------- ------------------------------
ADWU SHPMT_GDF_HIST_FCT_NEW TABLE SUBPARTITION 但是这个等待事件不是 发生在index 上面,而是 发生在 table上!!! 也许你觉得 用object_id定位不准确,那么我用 file#,block#定位,同样发生在 table上 SQL> set lines 200
SQL> set pages 100
SQL> set timi on
SQL> col owner format a30
SQL> col segment_name format a40
SQL> col segment_type format a30
SQL> select owner,segment_name,segment_type from dba_extents
2 where file_id=87 and 425778 between block_id and block_id+blocks-1; OWNER SEGMENT_NAME SEGMENT_TYPE
------------------------------ ---------------------------------------- ------------------------------
ADWU SHPMT_GDF_HIST_FCT_NEW TABLE SUBPARTITION 为什么db file sequential read 发生在 table上呢?怀疑是行迁移/行连接(具体请看Metalink) Full Table Scans On A Table Is Reading 1 Block At A Time. (Due To Chained / Migrated Rows) [ID 554366.1] SQL> select c.sid,c.username,b.name,a.value,trunc(a.value/(select sum(value) from v$sesstat a,v$statname b
2 where a.statistic#=b.statistic# and b.name='table fetch continued row'),4)*100 ||'%' pct_used
3 from v$sesstat a, v$statname b,v$session c where a.statistic# =b.statistic# and b.name='table fetch continued row'
4 and a.sid=c.sid and c.sid=4848; SID USERNAME NAME VALUE PCT_USED
---------- ------------------------------ ------------------------------ ---------- -----------------------------------------
4848 BW9518 table fetch continued row 8 .04% 更加让我怀疑是行迁移/行连接 那么现在Analyze表 analyze table adwu.SHPMT_GDF_HIST_FCT_NEW compute statistics;
由于表很大(8亿多数据)。。。等Analyze完了再更新博客。。。 SQL> select s.inst_id, s.sid, s.serial#, s.event,
2 q.sql_text
3 from gv$session s, gv$sql q, gv$session_longops l
4 where s.inst_id = q.inst_id(+)
5 and s.sql_id = q.sql_id(+)
6 and s.inst_id = l.inst_id(+)
7 and s.sid = l.sid(+)
8 and s.serial# = l.serial#(+)
9 and s.username like upper('BW9518')
10 group by s.inst_id, s.sid, s.serial#, s.username, s.logon_time, s.status, s.sql_id, s.machine, s.LAST_CALL_ET, s.event, q.sql_text, q.PLAN_HASH_VALUE
11 ; INST_ID SID SERIAL# EVENT SQL_TEXT
---------- ---------- ---------- ---------------------------------------- --------------------------------------------------------------------------------
1 4669 59 PX Deq: Execution Msg select s.inst_id, s.sid, s.serial#, s.event, q.sql_text from gv$sessio
1 4791 2987 db file sequential read analyze table adwu.SHPMT_GDF_HIST_FCT_NEW compute statistics
1 4817 3318 SQL*Net message from client select s.inst_id, s.sid, s.serial#, s.event, q.sql_text from gv$sessio
1 4820 2427 SQL*Net message from client
1 4826 2013 SQL*Net message from client
1 4848 1325 gc cr request SELECT i.initv_skid, f.prod_csu_type_code, i.time_perd_ski
2 4809 49553 db file sequential read SELECT i.initv_skid, f.prod_csu_type_code, i.ti
2 4859 10363 PX Deq: reap credit select s.inst_id, s.sid, s.serial#, s.event, q.sql_text from gv$sessio
3 4830 1778 PX Deq: reap credit select s.inst_id, s.sid, s.serial#, s.event, q.sql_text from gv$sessio
4 4827 4452 PX Deq: reap credit select s.inst_id, s.sid, s.serial#, s.event, q.sql_text from gv$sessio 10 rows selected 更新--------- SQL> select table_name,pct_free from ALL_TAB_PARTITIONS where table_name='SHPMT_GDF_HIST_FCT_NEW'; TABLE_NAME PCT_FREE
------------------------------ ----------
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0
SHPMT_GDF_HIST_FCT_NEW 0 39 rows selected 这个表PCF_FREE=0,ANALYZE 已经没必要等了 现在已经明确问题了,表上面肯定有很多行迁移/连接,analyze 都给我来db file sequential read 总结:对于 db file sequential read 表示单块读,出现该等待事件并不是 表示说 一定是读索引,也有可能是读表,如果有大量等待事件发生在表上面,那么很可能出现行迁移/连接。 单块读:要么是行迁移,要么是UNDO pct_free=0 稍微update一下就产生hang迁移


												

全表扫描引发的db file sequential read的更多相关文章

  1. 读UNDO引发的db file sequential read

    SQL> select * from (select SESSION_ID, NAME, P1, P2, P3, WAIT_TIME, CURRENT_OBJ#, CURRENT_FILE#, ...

  2. 全表扫描出现db file sequential read

    SESSION 1执行 SQL> update test1 set id=1000; SESSION 2 : select * from test1 如果表上面有大量的行迁链接,会是单块读等待事 ...

  3. 常识之外:全表扫描为何产生大量 db file sequential read 单块读?

    原创 2016-07-05 熊军 Oracle   编辑手记:在理解Oracle技术细节时,我们不仅应该读懂概念,还要能够通过测试验证细节,理解那些『功夫在诗外』的部分,例如全表扫描和单块读. 开发人 ...

  4. 何时会发生db file sequential read等待事件?

    很多网友对系统内频繁发生的db file sequential read等待事件存有疑问,那么到底在那些场景中会触发该单块读等待事件呢? 在我之前写的一篇博文<SQL调优:Clustering ...

  5. db file sequential read (数据文件顺序读取)

    转载:http://www.dbtan.com/2010/04/db-file-sequential-read.html db file sequential read (数据文件顺序读取): db ...

  6. Oracle 等待事件 db file sequential read

    db file sequential read-数据文件顺序读取 等待事件: "db file sequential read" Reference Note (文档 ID 345 ...

  7. oracle之 db file sequential read等待事件优化思想

    为什么db file sequential read事件在full table scan操作中显现,为什么在多块读中为什么会有单块读存在 ? extent的大小 :当扩展区中的最后一组块仅是1个块,o ...

  8. 模拟等待事件:db file sequential read

    相关知识: db file sequential read  单块读 optimizer_index_cost_adj 这个初始化参数代表一个百分比,取值范围在1到10000之间.该参数表示索引扫描和 ...

  9. db file sequential read等待事件 --转载

    db file sequential read db file sequential read等待事件有3个参数:file#,first block#,和block数量.在10g中,这等待事件受到用户 ...

随机推荐

  1. [转] Git 分支 - 分支的新建与合并

    http://git-scm.com/book/zh/v1/Git-%E5%88%86%E6%94%AF-%E5%88%86%E6%94%AF%E7%9A%84%E6%96%B0%E5%BB%BA%E ...

  2. Android关闭系统锁屏

    昨晚探索了一下Android系统内的目录,意外发现系统锁屏的数据库 使用adb shell进入系统根目录 adb shell su sqlite3 data/system/locksettings.d ...

  3. COGS 859. 数列

    /* 先来说一下第一眼看到想出的奇葩方法23333.. 找每个数左右有几个比他小的 前几天刚学了区间第k小的求法 然后... 枚举中间的那个点 对于左区间 二分找到他是第几大 右区间同理 然后 *起来 ...

  4. ajax提交富文本,内容被截断,解决方法及思路

    问题描述: 使用百度的UEditor富文本插件用于前端富文本编辑,后端使用jsp,提交普通文本没有问题,后来发现在提交某些指定文本时,数据查回的数据出现不完整现象:第一件事就是想到“垃圾编辑器”

  5. javascript中this的解析

    在JavaScript中,this 的概念比较复杂.除了在面向对象编程中,this 还是随处可用的.这篇文章介绍了this 的工作原理,它会造成什么样的问题以及this 的相关例子. 要根据this  ...

  6. Linq101-Projection

    using System; using System.Linq; namespace Linq101 { class Projection { /// <summary> /// This ...

  7. Linux下解决高并发socket最大连接数所受的各种限制(解除IO限制)

    linux作为服务器系统,当运行高并发TCP程序时,通常会出现连接建立到一定个数后不能再建立连接的情况 本人在工作时,测试高并发tcp程序(GPS服务器端程序),多次测试,发现每次连接建立到3800左 ...

  8. dbms_job dbms_scheduler简单比较

    ---------------------------陈旧的-------------------------------------/*--------------------- 创建job --- ...

  9. 说说RMAN里的obsolete

    RMAN> report obsolete; RMAN retention policy will be applied to the commandRMAN retention policy ...

  10. WPF实现摄像头镜像翻转

    之前的项目需要镜像翻转摄像头视频,使用Aforge.Net来处理视频. 一开始考虑直接从Aforge.Net读取没一帧视频图片,然后复制给WPF的Image控件,这种方法基本很卡,所以放弃了. 考虑到 ...