Chinaunix首页 | 论坛 | 博客
  • 博客访问: 98687
  • 博文数量: 12
  • 博客积分: 2041
  • 博客等级: 大尉
  • 技术积分: 340
  • 用 户 组: 普通用户
  • 注册时间: 2005-11-20 16:32
文章分类
文章存档

2010年(4)

2009年(5)

2008年(3)

我的朋友

分类: Oracle

2009-07-18 18:18:19

系统存在严重的性能问题,IO十分高,DB CACHE的命中率不足50&。经分析HASH VALUE为1285325803的SQL存在严重的性能问题,通过SPREPSQL分析:

SQL Statistics

~~~~~~~~~~~~~~

-> CPU and Elapsed Time are in seconds (s) for Statement Total and in

milliseconds (ms) for Per Execute

% Snap

Statement Total Per Execute Total

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

Buffer Gets: 1,055,004 36,379.4 32.81

Disk Reads: 1,000,975 34,516.4 46.02

Rows processed: 159 5.5

CPU Time(s/ms): 113 3,889.3

Elapsed Time(s/ms): 318 10,976.9

Sorts: 29 1.0

Parse Calls: 29 1.0

Invalidations: 0

Version count: 1

Sharable Mem(K): 49

Executions: 29



SQL Text

~~~~~~~~

select b.req_name, b.cli_pid

, b.req_id, b.svr_name, b.timeout, b.svr_module,

b.svr_inst, b.status, to_char(b.req_tm, 'YYYY MM DD HH24 MI SS'),

nvl(a.default_timeout,0)

from service_list a, service_req_list b

where

a.app_id(+) = b.app_id and

a.svr_name(+) = b.svr_name and

b.status in ('Q','A') and

b.app_id = :v1 order by b.req_tm,b.req_id



Known Optimizer Plan(s) for this Hash Value

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Shows all known Optimizer Plans for this database instance, and the Snap Id's

they were first found in the shared pool. A Plan Hash Value will appear

multiple times if the cost has changed

-> ordered by Snap Id



First First Plan

Snap Id Snap Time Hash Value Cost

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

167 24 Sep 08 16:57 74934330 40682



Plans in shared pool between Begin and End Snap Ids

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Shows the Execution Plans found in the shared pool between the begin and end

snapshots specified. The values for Rows, Bytes and Cost shown below are those

which existed at the time the first-ever snapshot captured this plan - these

values often change over time, and so may not be indicative of current values

-> Rows indicates Cardinality, PHV is Plan Hash Value

-> ordered by Plan Hash Value



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

| Operation | PHV/Object Name | Rows | Bytes| Cost |

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

|SELECT STATEMENT |----- 74934330 ----- | | | 40682 |

|SORT ORDER BY | | 1M| 190M| 40682 |

| HASH JOIN OUTER | | 1M| 190M| 8355 |

| TABLE ACCESS FULL |SERVICE_REQ_LIST | 1M| 147M| 5641 |

| TABLE ACCESS BY INDEX ROWID |SERVICE_LIST | 15 | 345 | 2 |

| INDEX RANGE SCAN |PINX_SERVICE_LIST$_A | 1 | | 1 |

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



对SERVICE_REQ_LIST的全表扫描是引起性能问题的关键,该表有超过100万条记录。在该表上存在下列过滤条件:

b.status in ('Q','A') and

b.app_id = :v1

经检查,b.app_id的值域只有一个值,无选择性。而b.status只有很少的值:

SQL> select status,count(*) from acsdba.service_req_list group by status;



S COUNT(*)

- ----------

A 2

C 2304679

E 367

Q 1



幸运的是该SQL查找的STATUS IN('A','Q')的记录只有几条。因此STATUS上的创建索引可以有效减少全表扫描。经检查在STATUS字段上已经创建了索引,但是该索引并没有起作用,经检查,发现是由于没有分析柱状图引起。通过下列脚本对该表进行重新分析:



exec DBMS_STATS.GATHER_TABLE_STATS(ownname=>'acsdba', tabname=>'service_req_list', estimate_percent=>20, -

method_o> pt=>'for all indexed columns size skewonly',cascade=>true, degree=>2);



分析后检查执行计划:

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

| Operation | PHV/Object Name | Rows | Bytes| Cost |

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

|SELECT STATEMENT |----- 10932168 ----- | | | 25 |

|SORT ORDER BY | | 1 | 102 | 25 |

| NESTED LOOPS OUTER | | 1 | 102 | 5 |

| INLIST ITERATOR | | | | |

| TABLE ACCESS BY INDEX ROWID |SERVICE_REQ_LIST | 1 | 79 | 4 |

| INDEX RANGE SCAN |RINX_SERVICE_REQ$_LI | 1 | | 3 |

| TABLE ACCESS BY INDEX ROWID |SERVICE_LIST | 1 | 23 | 1 |

| INDEX UNIQUE SCAN |UINX_SERVICE_LIST$_A | 1 | | |

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



发现全表扫描已经消除,通过9月25日上午的验证,系统的整体性能有了较大提升
阅读(1687) | 评论(2) | 转发(0) |
0

上一篇:功夫熊猫经典台词

下一篇:HPUX下wget安装

给主人留下些什么吧!~~

chinaunix网友2009-07-18 18:22:30

在OLTP中一般是关闭柱状图的收集, 设置FOR ALL COLUMNS SIZE 1 即可。

chinaunix网友2009-07-18 18:19:21

如果你有一个高度倾斜的索引(某些值的行数不对称),就可创建Oracle直方图统计。但在现实世界中,出现这种情况的机率相当小。使用CBO时,最常见的错误之一就是在CBO统计中不必要地引入直方图。根据经验,只有在列值要求必须修改执行计划时,才应使用直方图。 'for all indexed columns size skewonly skewonly选项会耗费大量处理时间,因为它要检查每个索引中的每个列的值的分布情况。