当前位置: 代码迷 >> SQL >> Oracle 通过AWR的SQL ordered by Gets和SQL ordered by Reads诊断有关问题
  详细解决方案

Oracle 通过AWR的SQL ordered by Gets和SQL ordered by Reads诊断有关问题

热度:385   发布时间:2016-05-05 10:27:22.0
Oracle 通过AWR的SQL ordered by Gets和SQL ordered by Reads诊断问题

    之前看过很多数据库报告,直到最近出现过两次严重的性能问题,非常有代表性,所以记录下来。

   一次是报Oracle进程把数据库服务器的CPU弄到100%

    SQL ordered by Gets  是在内存中取数据,单位是次,是消耗CPU的主要源头,在调试SQL的时候,大部分时候都是通过它来衡量性能。下面是实际的AWR报告,相当骇人啊:

SQL ordered by Gets

  • Resources reported for PL/SQL code includes the resources used by all SQL statements called by the code.
  • Total Buffer Gets: ###############
  • Captured SQL account for 5.0% of Total
Buffer GetsExecutionsGets per Exec%TotalCPU Time (s)Elapsed Time (s)SQL IdSQL ModuleSQL Text
1,606,380,3908419,123,576.07-0.8437923.62207407.5478tpfukr4m00pJDBC Thin Clientselect sum(temp.MidUser) total...
1,479,957,4450 -0.7726647.4843778.622mxgaus0t6pxzJDBC Thin ClientSELECT 设备ID SBID, 设备ID SBBM, 设...
1,280,365,0927317,539,247.84-0.6730263.02159789.712qrj96dwj2xx1JDBC Thin Clientselect sum(temp.MidUser) total...
1,163,229,2405182,245,616.29-0.6111775.7230158.95cq0adyp396538JDBC Thin ClientSELECT COUNT(*) FROM DM_FL_OBJ...
465,618,3082611,783,978.19-0.2411004.4927015.23acqqmk9b7vc4aJDBC Thin ClientSELECT COUNT(*) FROM DM_FL_OBJ...
448,728,3012121,368,014.33-0.2310698.4343934.2624gvfb62gt1ydJDBC Thin Clientselect sum(temp.MidUser) total...
386,047,3292416,085,305.38-0.209286.2745034.84fx8tp01tpwgkqJDBC Thin Clientselect sum(temp.MidUser) total...
294,571,9061322,659,377.38-0.157002.7326477.59383ut78zg00hqJDBC Thin Clientselect sum(temp.MidUser) total...
274,341,5271419,595,823.36-0.146415.8326625.21cqhbuuz14x7ghJDBC Thin Clientselect sum(temp.MidUser) total...
176,633,3051017,663,330.50-0.094160.8226360.289xc9701y82st9JDBC Thin Clientselect sum(temp.MidUser) total...

     解决方案:调优SQL

    一次是数据库服务器IO负载已经达到极限

    SQL ordered by Reads  去磁盘取数据,单位是次,如果太大,IO会导致整个数据库慢,是RAC的环境,可能会导致数据库重启。

     在数据库top5的等待事件中,可以看到direct path read非常大。
    Oracle 11g中_small_table_threshold参数是大表的界定,当表大小小于这个值时,就会对表进行缓存。它的值在实例启动时动态决定,一般为 2% * DB_CACHE_SIZE,单位是block。所以依据系统的情况可以固定。

     解决方案:调优SQL、调大SGA、调大_small_table_threshold

  相关解决方案