查看: 15494|回复: 13

direct path read temp等待如何解决

[复制链接]
论坛徽章:
13
铁扇公主
日期:2008-08-23 12:15:03奥运会纪念徽章:足球
日期:2008-08-28 20:19:082009日食纪念
日期:2009-07-22 09:30:002010年世界杯参赛球队:葡萄牙
日期:2010-03-11 08:38:072010年世界杯参赛球队:加纳
日期:2010-03-17 14:44:352012新春纪念徽章
日期:2012-01-04 11:53:29奥运会纪念徽章:拳击
日期:2012-06-18 16:33:22蛋疼蛋
日期:2013-04-03 16:41:24
跳转到指定楼层
1#
发表于 2008-11-19 10:21 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
SQL> select * from v$session_wait where event = 'direct path read temp';

SID  SEQ#   EVENT                          P1TEXT        P1   P1RAW                      P2TEXT         P2          P2RAW           
----   -----      ----------------------         -----------      ---   ----------------             ---------        -------       ----------------
321 30451   direct path read temp  file number 201 00000000000000C9  first dba      1669385 0000000000197909

P3TEXT    P3 P3RAW                       WAIT_CLASS_ID WAIT_CLASS# WAIT_CLASS  WAIT_TIME SECONDS_IN_WAIT   STATE            
---------    --  ----------------                -------------           -----------         ----------          ----------      ---------------               -----------------
block cnt  1  0000000000000001    1740759767           8                   User I/O           -1               8                            WAITED SHORT TIME

一个过程正常的话几秒就执行完了,但最近该过程执行到一个insert的时候出现了这个等待事件,15000多秒还没执行完。
请问一般情况下都有哪些原因,也就是我需要确认哪些东西是否正常
另外,要如何解决,谢谢!!!

p1=201是临时文件,观察了一下,平均12秒左右读一个block
论坛徽章:
27
会员2007贡献徽章
日期:2007-09-26 18:42:102011新春纪念徽章
日期:2011-02-18 11:43:342010广州亚运会纪念徽章:排球
日期:2011-03-03 12:19:332010广州亚运会纪念徽章:篮球
日期:2011-03-10 14:25:06ITPUB十周年纪念徽章
日期:2011-09-27 16:30:47ITPUB十周年纪念徽章
日期:2011-11-01 16:21:15灰彻蛋
日期:2011-12-28 16:56:322012新春纪念徽章
日期:2012-01-04 11:50:44迷宫蛋
日期:2012-03-09 15:14:20蜘蛛蛋
日期:2012-03-26 09:46:32
2#
发表于 2008-11-19 10:25 | 只看该作者
看看是否有 一些 不合理的 磁盘排序
排序区是否太小?

使用道具 举报

回复
招聘 : Linux运维
论坛徽章:
42
奥运会纪念徽章:跳水
日期:2008-09-08 16:00:45茶鸡蛋
日期:2013-01-18 12:36:552013年新春福章
日期:2013-02-25 14:51:24复活蛋
日期:2013-03-28 19:57:20茶鸡蛋
日期:2013-07-05 08:59:54茶鸡蛋
日期:2013-07-08 10:01:05福特
日期:2013-08-06 10:13:26马上有车
日期:2014-03-26 10:47:51马上有对象
日期:2014-04-28 13:43:04马上有钱
日期:2014-07-19 16:38:11
3#
发表于 2008-11-19 10:28 | 只看该作者
找出原因来
10.3.5 direct path read and direct path read tempWhen a session is reading buffers from disk directly into the PGA (opposed to the buffer cache in SGA), it waits on this event. If the I/O subsystem does not support asynchronous I/Os, then each wait corresponds to a physical read request.
If the I/O subsystem supports asynchronous I/O, then the process is able to overlap issuing read requests with processing the blocks already existing in the PGA. When the process attempts to access a block in the PGA that has not yet been read from disk, it then issues a wait call and updates the statistics for this event. Hence, the number of waits is not necessarily the same as the number of read requests (unlike db file scattered read and db file sequential read).
Check the following V$SESSION_WAIT parameter columns:
  • P1 - File_id for the read call
  • P2 - Start block_id for the read call
  • P3 - Number of blocks in the read call
10.3.5.1 CausesThis happens in the following situations:
  • The sorts are too large to fit in memory and some of the sort data is written out directly to disk. This data is later read back in, using direct reads.
  • Parallel slaves are used for scanning data.
  • The server process is processing buffers faster than the I/O system can return the buffers. This can indicate an overloaded I/O system.

10.3.5.2 ActionsThe file_id shows if the reads are for an object in TEMP tablespace (sorts to disk) or full table scans by parallel slaves. This is the biggest wait for large data warehouse sites. However, if the workload is not a DSS workload, then examine why this is happening.
10.3.5.2.1 Sorts to DiskExamine the SQL statement currently being run by the session experiencing waits to see what is causing the sorts. Query V$TEMPSEG_USAGE to find the SQL statement that is generating the sort. Also query the statistics from V$SESSTAT for the session to determine the size of the sort. See if it is possible to reduce the sorting by tuning the SQL statement. If WORKAREA_SIZE_POLICY is MANUAL, then consider increasing the SORT_AREA_SIZE for the system (if the sorts are not too big) or for individual processes. If WORKAREA_SIZE_POLICY is AUTO, then investigate whether to increase PGA_AGGREGATE_TARGET. See "PGA Memory Management".

10.3.5.2.2 Full Table ScansIf tables are defined with a high degree of parallelism, then this could skew the optimizer to use full table scans with parallel slaves. Check the object being read into using the direct path reads. If the full table scans are a valid part of the workload, then ensure that the I/O subsystem is configured adequately for the degree of parallelism. Consider using disk striping if you are not already using it or Automatic Storage Management (ASM).

10.3.5.2.3 Hash Area SizeFor query plans that call for a hash join, excessive I/O could result from having HASH_AREA_SIZE too small. If WORKAREA_SIZE_POLICY is MANUAL, then consider increasing the HASH_AREA_SIZE for the system or for individual processes. If WORKAREA_SIZE_POLICY is AUTO, then investigate whether to increase PGA_AGGREGATE_TARGET.

使用道具 举报

回复
论坛徽章:
13
铁扇公主
日期:2008-08-23 12:15:03奥运会纪念徽章:足球
日期:2008-08-28 20:19:082009日食纪念
日期:2009-07-22 09:30:002010年世界杯参赛球队:葡萄牙
日期:2010-03-11 08:38:072010年世界杯参赛球队:加纳
日期:2010-03-17 14:44:352012新春纪念徽章
日期:2012-01-04 11:53:29奥运会纪念徽章:拳击
日期:2012-06-18 16:33:22蛋疼蛋
日期:2013-04-03 16:41:24
4#
 楼主| 发表于 2008-11-19 10:42 | 只看该作者
原帖由 carcase 于 2008-11-19 10:25 发表
看看是否有 一些 不合理的 磁盘排序
排序区是否太小?


请问一下什么是 不合理的 磁盘排序?
pga_aggregate_target是1G,我想已经够大了

使用道具 举报

回复
论坛徽章:
13
铁扇公主
日期:2008-08-23 12:15:03奥运会纪念徽章:足球
日期:2008-08-28 20:19:082009日食纪念
日期:2009-07-22 09:30:002010年世界杯参赛球队:葡萄牙
日期:2010-03-11 08:38:072010年世界杯参赛球队:加纳
日期:2010-03-17 14:44:352012新春纪念徽章
日期:2012-01-04 11:53:29奥运会纪念徽章:拳击
日期:2012-06-18 16:33:22蛋疼蛋
日期:2013-04-03 16:41:24
5#
 楼主| 发表于 2008-11-19 10:51 | 只看该作者
#3的这段话我也一直在看,但还是不得要领
1、不是排序区太小
2、没有并行
3、The server process is processing buffers faster than the I/O system can return the buffers,这个有可能
但我的系统有很多过程在执行,而且处理的数据量比这个过程要大的多都没问题的
感觉要么和这个语句的执行计划有关,要么和其中的某个表有关
大致语句是:insert into t(...) select * from a,b,c,d where ...
看执行计划,对其中一个表(7000记录)做sort join,然后和另一个表的索引做merge join,没有其他排序操作

使用道具 举报

回复
论坛徽章:
27
会员2007贡献徽章
日期:2007-09-26 18:42:102011新春纪念徽章
日期:2011-02-18 11:43:342010广州亚运会纪念徽章:排球
日期:2011-03-03 12:19:332010广州亚运会纪念徽章:篮球
日期:2011-03-10 14:25:06ITPUB十周年纪念徽章
日期:2011-09-27 16:30:47ITPUB十周年纪念徽章
日期:2011-11-01 16:21:15灰彻蛋
日期:2011-12-28 16:56:322012新春纪念徽章
日期:2012-01-04 11:50:44迷宫蛋
日期:2012-03-09 15:14:20蜘蛛蛋
日期:2012-03-26 09:46:32
6#
发表于 2008-11-19 10:54 | 只看该作者
就是 这段时间内的 排序太多了
你的pga是1G,5%是50M,排序大于50M,就是要磁盘排序,磁盘排序多 可以理解为 不合理

你可以手工 执行一下你的sql语句,看看sort(disk) 是不是多

使用道具 举报

回复
论坛徽章:
13
铁扇公主
日期:2008-08-23 12:15:03奥运会纪念徽章:足球
日期:2008-08-28 20:19:082009日食纪念
日期:2009-07-22 09:30:002010年世界杯参赛球队:葡萄牙
日期:2010-03-11 08:38:072010年世界杯参赛球队:加纳
日期:2010-03-17 14:44:352012新春纪念徽章
日期:2012-01-04 11:53:29奥运会纪念徽章:拳击
日期:2012-06-18 16:33:22蛋疼蛋
日期:2013-04-03 16:41:24
7#
 楼主| 发表于 2008-11-19 13:18 | 只看该作者
select * from V$SESSTAT a,v$statname b
where a.STATISTIC# = b.STATISTIC# and name like '%sorts%' and sid = 294

sid          statistic#  value        name                      class        stat_id
294        349        688910        sorts (memory)        64        2091983730
294        350        1        sorts (disk)        64        2533123502
294        351        2962856        sorts (rows)        64        3757672740

不知道这样是不是正常?

使用道具 举报

回复
论坛徽章:
27
会员2007贡献徽章
日期:2007-09-26 18:42:102011新春纪念徽章
日期:2011-02-18 11:43:342010广州亚运会纪念徽章:排球
日期:2011-03-03 12:19:332010广州亚运会纪念徽章:篮球
日期:2011-03-10 14:25:06ITPUB十周年纪念徽章
日期:2011-09-27 16:30:47ITPUB十周年纪念徽章
日期:2011-11-01 16:21:15灰彻蛋
日期:2011-12-28 16:56:322012新春纪念徽章
日期:2012-01-04 11:50:44迷宫蛋
日期:2012-03-09 15:14:20蜘蛛蛋
日期:2012-03-26 09:46:32
8#
发表于 2008-11-19 13:39 | 只看该作者
select sql_text,operation_type,policy,last_memory_used/1024/1024,last_execution,last_tempseg_size
from v$sql l,v$sql_workarea a
where l.hash_value=a.hash_value
and sql_text like '%select object_name from test3 order by owner%';

select object 用你的sql代替   
2962856        sorts (rows)   292万的排序 有点多吧

使用道具 举报

回复
论坛徽章:
13
铁扇公主
日期:2008-08-23 12:15:03奥运会纪念徽章:足球
日期:2008-08-28 20:19:082009日食纪念
日期:2009-07-22 09:30:002010年世界杯参赛球队:葡萄牙
日期:2010-03-11 08:38:072010年世界杯参赛球队:加纳
日期:2010-03-17 14:44:352012新春纪念徽章
日期:2012-01-04 11:53:29奥运会纪念徽章:拳击
日期:2012-06-18 16:33:22蛋疼蛋
日期:2013-04-03 16:41:24
9#
 楼主| 发表于 2008-11-19 14:05 | 只看该作者
select sql_text,operation_type,policy,last_memory_used/1024/1024,last_execution,last_tempseg_size
from v$sql l,v$sql_workarea a
where l.hash_value=a.hash_value
and l.sql_id = '5q7a34qct8fun'

SQL_TEXT                               OPERATION_TYPE   POLICY   LAST_MEMORY_USED/1024/1024 LAST_EXECUTION       LAST_TEMPSEG_SIZE
------------------------                 ----------------           -------- --------------------------                        --------------------          -----------------
INSERT INTO OFENTRUST SE   BUFFER                   AUTO                              0                            OPTIMAL

[ 本帖最后由 homeworld80 于 2008-11-19 14:06 编辑 ]

使用道具 举报

回复
招聘 : 数据库管理员
论坛徽章:
16
2009新春纪念徽章
日期:2009-01-04 14:52:282014年新春福章
日期:2014-02-18 16:43:092013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-09 18:09:19奥运会纪念徽章:艺术体操
日期:2012-07-24 12:01:27奥运会纪念徽章:乒乓球
日期:2012-07-23 18:08:47奥运会纪念徽章:铁人三项
日期:2012-06-20 13:06:10ITPUB十周年纪念徽章
日期:2011-11-01 16:24:512011新春纪念徽章
日期:2011-02-18 11:43:332010广州亚运会纪念徽章:游泳
日期:2010-10-19 11:09:06
10#
发表于 2008-11-19 14:08 | 只看该作者
也用这条语句
select se.USERNAME,
       se.OSUSER,
       se.SID,
       p.SPID,
       su.BLOCKS * 8192/1024/1024 Space,
       s.SQL_TEXT
  from v$sort_usage su, v$session se, v$sqltext s, v$process p
where su.SESSION_ADDR = se.SADDR
   and se.SQL_ADDRESS = s.ADDRESS
   and se.SQL_HASH_VALUE = s.HASH_VALUE
   and p.ADDR = se.PADDR;

查出来sql  然后看看 为什么会有那么多的排序

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表