全表扫描引发的db file sequential read
今天我要做一个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的更多相关文章
- 读UNDO引发的db file sequential read
SQL> select * from (select SESSION_ID, NAME, P1, P2, P3, WAIT_TIME, CURRENT_OBJ#, CURRENT_FILE#, ...
- 全表扫描出现db file sequential read
SESSION 1执行 SQL> update test1 set id=1000; SESSION 2 : select * from test1 如果表上面有大量的行迁链接,会是单块读等待事 ...
- 常识之外:全表扫描为何产生大量 db file sequential read 单块读?
原创 2016-07-05 熊军 Oracle 编辑手记:在理解Oracle技术细节时,我们不仅应该读懂概念,还要能够通过测试验证细节,理解那些『功夫在诗外』的部分,例如全表扫描和单块读. 开发人 ...
- 何时会发生db file sequential read等待事件?
很多网友对系统内频繁发生的db file sequential read等待事件存有疑问,那么到底在那些场景中会触发该单块读等待事件呢? 在我之前写的一篇博文<SQL调优:Clustering ...
- db file sequential read (数据文件顺序读取)
转载:http://www.dbtan.com/2010/04/db-file-sequential-read.html db file sequential read (数据文件顺序读取): db ...
- Oracle 等待事件 db file sequential read
db file sequential read-数据文件顺序读取 等待事件: "db file sequential read" Reference Note (文档 ID 345 ...
- oracle之 db file sequential read等待事件优化思想
为什么db file sequential read事件在full table scan操作中显现,为什么在多块读中为什么会有单块读存在 ? extent的大小 :当扩展区中的最后一组块仅是1个块,o ...
- 模拟等待事件:db file sequential read
相关知识: db file sequential read 单块读 optimizer_index_cost_adj 这个初始化参数代表一个百分比,取值范围在1到10000之间.该参数表示索引扫描和 ...
- db file sequential read等待事件 --转载
db file sequential read db file sequential read等待事件有3个参数:file#,first block#,和block数量.在10g中,这等待事件受到用户 ...
随机推荐
- HDU 4622 多校第三场1002 后缀自动机
比赛的时候我是用后缀数组的,但是T了. 赛后看了解题报告说,后缀数组貌似是卡你常数的时间,我算了下复杂度O(T * Q * n).这是10 ^ 8,但是考虑到每次询问的时候都要重新构造字符,所以那个n ...
- SQL Server通过整理索引碎片和重建索引提高速度
本文章转载:http://database.51cto.com/art/201108/282408.htm SQL Server数据库中,当索引碎片太多时,就会拖慢数据库查询的速度.这时我们可以通过整 ...
- weblogic数据源配置的问题,weblogic密码破解
weblogic 报错 please increase XXX,得知是连接池出了问题,查看weblogic配置,发现没有设置超时 查看oracle 当前session,可以看到连接的机器,用户,当前执 ...
- [AngularJS] Enable Animations Explicitly For A Performance Boost In AngularJS
http://www.bennadel.com/blog/2935-enable-animations-explicitly-for-a-performance-boost-in-angularjs. ...
- winserver2008下创建计划任务注意点
winserver2008下创建任务计划注意点: 1.建立独立用户,可以给其赋予administrator权限 2.起始于(可选):要填写exe文件所在路径 3.设置成“不管用户是否登录都运行”,同时 ...
- java中-静态代码块、构造代码块、构造方法的联系
例如该题: 1 class Fu{ static { System.out.println("这是父类静态代码块"); } { System.out.println("这 ...
- POJ 1330 Nearest Common Ancestors(LCA模板)
给定一棵树求任意两个节点的公共祖先 tarjan离线求LCA思想是,先把所有的查询保存起来,然后dfs一遍树的时候在判断.如果当前节点是要求的两个节点当中的一个,那么再判断另外一个是否已经访问过,如果 ...
- 本文实例汇总了C#中@的用法,对C#程序设计来说有不错的借鉴价值。
具体如下: 一 字符串中的用法 1.学过C#的人都知道C# 中字符串常量可以以@ 开头声名,这样的优点是转义序列“不”被处理,按“原样”输出,即我们不需要对转义字符加上 \ (反斜扛),就可以轻松co ...
- Wpf 数据绑定之BindingBase.StringFormat
BindingBase.StringFormat 属性获取或设置一个字符串,该字符串指定如果绑定值显示为字符串,应如何设置该绑定的格式. StringFormat 可以是预定义的.撰写的或自定义的字符 ...
- asp.net Request.ServerVariables[] 读解
获取客户端的IP地址,代码如下: /// <summary> /// 获取客户端IP地址 /// </summary> /// <returns></retu ...