`
streamsong
  • 浏览: 82511 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

关于read by other session,db file scattered read,db file sequential read等待时间的优化(下)

阅读更多

5tt2k7djxub2m

select t.unionorderid as serialid , t.lotteryid as lotteryid , fn_get_lotteryname(t.lotteryid) as lotterydesc , t.lotteryissue as issue , fn_get_username(t.uuid) as username , to_char(t.addtime, 'yyyy-mm-dd hh24:mi') as createtime , case when t.schstatus=1 and t.currentvalue<t.schemevalue and t.endtime>sysdate then fn_get_schstatusdesc(0) else fn_get_schstatusdesc(t.schstatus) end as schstatusdesc , to_char(t.bonustime, 'yyyy-mm-dd hh24:mi') as bonustime , t.bonusvalue as bonusvalue , t.schemevalue as lotteryvalue , case when t.schstatus=1 and t.currentvalue<t.schemevalue and t.endtime>sysdate then 0 else t.schstatus end as schstatus , case when t.schemeissue>1 then 1 else 0 end as issueflag , t.bonusstop as bonusstop , t.schemeissue as schemeissue , t.schtype as schtype , t.schemetitle as schemetitle , t.schemmemo as schemedesc , t.viewtype as viewtypedesc , t.schembonusrate as bon usrate , t.limitvalue as limitvalue , t.schemlowmoney as schemelowvalue , t.currentvalue as buyvalue , t.bodivalue as baodivalue , case when t.saletype=-1 and t.childtype=-1 then fn_get_saletypedesc(t.lotteryid, t.saletype, t.childtype) else fn_get_childtypedesc(t.lotteryid , t.childtype)||fn_get_saletypedesc(t.lotteryid, t.saletype, t.childtype) end as saletypedesc , fn_get_passbonus(t.unionorderid) as passbonus , case when t.viewtype=0 then t.schdetail when t.viewtype=1 and t.endtime<sysdate and t.uuid!='' then t.schdetail when t.uuid='' then t.schdetail when t.viewtype=3 and fn_check_schfollow(t.unionorderid, '')=1 then t.schdetail when t.viewtype=4 and fn_check_schfollow(t.unionorderid, '')=1 and t.endtime<sysdate and t.uuid!='' then t.schdetail else 'nulls' end as schdetail , t.schnumbers as schnumbers , fn_get_lotterylevelid(t.uuid, t.lotteryid) as lotterylevel , fn_get_buyvalues(t.unionorderid, t.uuid) as schbuyvalue , to_cha r(t.endtime, 'yyyy-mm-dd hh24:mi') as endtime , lotterynumbers , istop from (select a.*, rownum r from (select a.* from tb_lotteryschemeinfo a inner join tb_lottery_info b on a.lotteryid=b.lotteryid and a.lotteryissue=b.lotteryissue where 1=1 and b.status<1 and a.schtype in (2, 3) and a.agenterid=10000001 order by a.istop desc, case when a.schstatus>2 then 5 when a.schstatus=2 then 4 when a.schstatus=1 and a.currentvalue<a.schemevalue and a.endtime>sysdate then 0 when a.schstatus=0 and a.currentvalue<a.schemevalue then 0 else 1 end, a.currentvalue/a.schemevalue desc, a.bodivalue/a.schemevalue desc, a.schemevalue desc , (a.schemevalue-a.currentvalue-a.bodivalue) desc, fn_get_lottery levelid(a.uuid, a.lotteryid) desc ) a where rownum <= 16) t where t.r > 0

首先想到的是查看算起来的执行计划,先看sql_id0ygf63rbau963sql

SQL> set line 1200

SQL>set autotrace traceonly explain

SQL> set timing on

SQL> select * from ( select row_.*, rownum rownum_ from ( select this_.ID as ID3_0_, this_.ART_ID as ART2_3_0_, this_.COM_CONTENT as COM3_3_0_, this_.COM_NAME as COM4_3_0_, this_.COM_TIME as COM5_3_0_, this_.TZZ_ID as TZZ6_3_0_ from ZHCWSQ.TZZ_ARTICLE_COMMENT this_ where this_.ART_ID=662 order by this_.ID desc ) row_ where rownum <=11) where rownum_ >5;

no rows selected

 

Elapsed: 00:04:23.01

 

Execution Plan

--------------------------------------------------------------------------------------------

| Id  | Operation                      | Name                   | Rows  | Bytes | Cost (%CPU)|

--------------------------------------------------------------------------------------------

|   0 | SELECT STATEMENT               |                        |    11 | 22990 |  9683   (1)|

|   1 |  VIEW                          |                        |    11 | 22990 |  9683   (1)|

|   2 |   COUNT STOPKEY                |                        |       |       |           |

|   3 |    VIEW                        |                        |    12 | 24924 |  9683   (1)|

|   4 |     TABLE ACCESS BY INDEX ROWID| TZZ_ARTICLE_COMMENT    |   810 |  2023K|  9683   (1)|

|   5 |      INDEX FULL SCAN DESCENDING| PK_TZZ_ARTICLE_COMMENT | 10860 |       |    30   (0)|

--------------------------------------------------------------------------------------------

 

看到这个sql走的是索引,但是423秒才查完76万条记录的表,这让我想到了db file sequential read等待事件,可能是因为这张表的索引建立的不正确,查看这张表的索引信息

SQL> set autotrace off

SQL>selectINDEX_OWNER,INDEX_NAME,TABLE_OWNER,TABLE_NAME,COLUMN_NAME from dba_ind_columns where table_name='TZZ_ARTICLE_COMMENT';

 

INDEX_OWNER  INDEX_NAME               TABLE_OWNE     TABLE_NAME            COLUMN_NAM

-----------  ----------------------   ----------     -----------------     -----------

ZHCWSQ       PK_TZZ_ARTICLE_COMMENT   ZHCWSQ         TZZ_ARTICLE_COMMENT   ID

发现这张表只有ID字段有索引,而查询用到的where条件的字段ART_ID并没有索引,执行计划中走的是INDEX FULL

通过观察sql_id7pn5pxb6sdususql也是这种情况。

再看下sql_id5tt2k7djxub2m的大sql,还是看下索引情况

SQL> select * from  dba_indexes where table_name='TB_LOTTERYSCHEMEINFO';

 

no rows selected

 

SQL> select * from user_ind_columns where table_name='TB_LOTTERYSCHEMEINFO';

 

no rows selected

发现这个表竟然没有索引

现在已将情况向领导反映,等领导要求优化的时候建立相应的索引,在看下统计信息和执行计划,由于是生产环境,未经批准,不能操作,真急人啊。

1
2
分享到:
评论

相关推荐

    数据库性能监控

    db file sequential read(ms) log file parallel write(ms) log file sync(ms) db file scattered read(ms) #IO WorkLoad Oracle IOPS Oracle MBPS db file sequential read db file scattered read log file ...

    Oracle等待事件说明一

    "Oracle等待事件说明一"主要关注了几个关键的等待事件,包括"buffer busy waits"、"db file parallel write"、"db file single write"、"db file scattered read"、"db file sequential read"以及"direct path write...

    ORACLE常见等待事件说明

    常见的非空闲等待事件包括 db file scattered read、db file sequential read、buffer busy waits、free buffer waits、enqueue、latch free、log file parallel write、log file sync 等。 1. db file scattered ...

    监控oracle的等待事件

    高频率的 db file scattered read 可能暗示需要对相关表创建合适的索引以优化查询性能。但并非所有情况下全表扫描都是性能低下的表现,Oracle 会根据访问数据量和优化器模式(CBO 或 RBO)来决定是否使用全表扫描。...

    Oracle缓冲区忙等待的识别和解决

    当“db file sequential read”和“db file scattered read”等读操作进入等待事件的前五名时,通常表示存在缓冲区忙等待问题。例如,以下STATSPACK报告片段显示了这些等待事件: ``` % 总和事件 等待 时间(s) 消逝...

    Oracle常见等待事件说明

    一些常见的非空闲等待事件有 db file scattered read、db file sequential read、buffer busy waits、free buffer waits、enqueue、latch free、log file parallel write、log file sync 等。 db file scattered ...

    oracle优化

    5. **等待事件**(Timed Events):db file scattered read、latch free、db file sequential read等是等待时间最多的事件。db file scattered read和db file sequential read涉及到I/O操作,可能需要优化表空间的I/...

    【故障处理】队列等待之TX 等待事件处理.docx

    - **Db file sequential read / scattered read**:这些等待事件通常涉及顺序读取和散列读取操作。优化索引使用,减少全表扫描,或者提升硬件性能(如磁盘I/O速度)有助于缓解。 - **Direct path read**:这是...

    Oracle数据库性能优化方法论.pptx

    IO等待事件,如db file scattered read和db file sequential read,直接影响数据的读写速度,优化I/O子系统和使用合适的数据访问模式至关重要。 在资源层面,CPU、内存和I/O是性能优化的重点。CPU资源的监控包括...

    Oracle数据库性能优化实务 数据文件IO.pptx

    通过识别消耗时间最多的事件,如`db file sequential read`和`db file scattered read`,可以定位性能瓶颈并采取相应措施进行优化。 综上所述,Oracle数据库性能优化涉及到多个层面,包括存储硬件、操作系统配置、...

    BLOG_Oracle_lhr_等待事件(1) User IO.pdf

    - **db file scattered read**:表示数据库服务器进程读取多个数据块时发生的等待事件。 - **db file sequential read**:表示顺序读取数据文件中的数据块时发生的等待事件。 - **db file parallel read**:在并行...

    oracle非空闲等待事件

    4. **DB File Sequential Read(顺序读)**:这是最常见的I/O等待事件之一,通常发生在全表扫描或索引扫描时。优化查询语句,减少全表扫描,可以降低这种等待。 5. **DB File scattered read(散列读)**:与顺序读...

    性能工程系列之一性能测试篇PPT学习教案.pptx

    非空闲等待事件,如buffer busy waits、db file scattered read、db file sequential read等,通常揭示了系统中的竞争和资源冲突,需要通过深入分析来解决。 针对I/O统计的诊断,可以使用SQL查询来获取表空间、...

    30种oracle常见的等待事件说明.zip_oracle

    3. **DB File Sequential Read**: 这个等待发生在数据文件的顺序读取操作中。优化索引使用、缓存策略(如增大SGA)和I/O子系统性能可以改善。 4. **DB File Scattered Read**: 当数据块非顺序读取时发生。数据库...

    oracle数据库笔试题.pdf

    db file sequential read 与 db file scattered read 等待的差别是什么?如果以上等待比较多,证明了什么问题?答案是:db file sequential read 是 DB 文件顺序读取,通常显示与单个数据块相关的读取操作(如索引...

    Oracle 性能问题一般解决思路

    - **db file scattered read**:若此类事件频繁,应检查相关SQL语句是否能有效利用索引,考虑调整查询语句或优化表结构,如创建合适的索引。 - **direct path read/write**:这通常与排序操作相关,可以通过增大PGA...

    Oracle-IO问题及性能调优

    1. **高I/O等待时间**:通过`v$sysstat`视图检查`db file sequential read`、`db file scattered read`等等待事件,若等待时间占比过高,可能存在I/O问题。 2. **慢查询**:长时间运行的SQL查询,可能由于频繁的...

Global site tag (gtag.js) - Google Analytics