temp表空间不足和direct path read/write temp事件

五一假期第一天上午不断收到核心数据库报警提示temp表空间不足。

关键字:temp表空间不足 direct path read/write temp事件 笛卡尔积

[@more@]

查询temp表空间使用情况,按占用temp从高到低排序

select v.USERNAME, v.SQL_ID, v.BLOCKS, s.SQL_TEXT, j.*

from v$tempseg_usage v,

v$sqlarea s,

(select * from v$session i where i.STATUS = 'ACTIVE') j

where v.SQL_ID = s.SQL_ID

and v.SESSION_ADDR = j.saddr

order by v.blocks desc;

发现大量类似SQL

select count(1)

from (select *

from ccic.prpjrecdetail

union all

select * from ccic.prpjrecdetailhis)

where receiptno = 'SDDK201214012155000168';

执行计划如下:

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

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

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

| 0 | SELECT STATEMENT | | 1 | 13 | 2 (0)| 00:00:01 |

| 1 | SORT AGGREGATE | | 1 | 13 | | |

| 2 | VIEW | | 2 | 26 | 2 (0)| 00:00:01 |

| 3 | UNION-ALL | | | | | |

|* 4 | INDEX RANGE SCAN| IND_JRECDETAIL_RECEIPTNO | 1 | 23 | 1 (0)| 00:00:01 |

|* 5 | INDEX RANGE SCAN| IND_JRECDETAILHIS_RECEIPTNO | 1 | 23 | 1 (0)| 00:00:01 |

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

Predicate Information (identified by operation id):

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

4 - access("PRPJRECDETAIL"."RECEIPTNO"='SDDK201214012155000168')

5 - access("PRPJRECDETAILHIS"."RECEIPTNO"='SDDK201214012155000168')

这些类似的SQL占用了大量的temp空间,超过150000块(1.2G)的就有5个,temp总大小16G。这些sql的问题是没有绑定变量,似乎不应该是造成频繁报警的原因。为了确定造成报警的原因,还是应该找到那个不断申请temp空间但又得不到满足的SQL

查询等待事件

select * from v$session v where v.STATUS='ACTIVE' and v.WAIT_CLASS<>'Idle';

发现direct path read/write temp事件,该事件对应的SQL

select a.riskcode,

/*省略部分*/

b.comcode as comcodey

/*省略部分*/

from (select *

from ccic.prpjpayrec

union all

select * from ccic.prpjrefrec) a,

ccic.PrpCmain b

where a.receiptno = :1;

执行计划如下

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

| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |

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

| 0 | SELECT STATEMENT | | 93M| 16G| 1263K (2)| 04:12:37 | | |

| 1 | MERGE JOIN CARTESIAN | | 93M| 16G| 1263K (2)| 04:12:37 | | |

| 2 | VIEW | | 2 | 336 | 2 (0)| 00:00:01 | | |

| 3 | UNION-ALL | | | | | | | |

| 4 | TABLE ACCESS BY INDEX ROWID| PRPJPAYREC | 1 | 167 | 1 (0)| 00:00:01 | | |

|* 5 | INDEX UNIQUE SCAN | PK_JPAYREC | 1 | | 1 (0)| 00:00:01 | | |

| 6 | TABLE ACCESS BY INDEX ROWID| PRPJREFREC | 1 | 160 | 1 (0)| 00:00:01 | | |

|* 7 | INDEX UNIQUE SCAN | PK_JREFREC | 1 | | 1 (0)| 00:00:01 | | |

| 8 | BUFFER SORT | | 46M| 977M| 1263K (2)| 04:12:37 | | |

| 9 | PARTITION RANGE ALL | | 46M| 977M| 631K (2)| 02:06:19 | 1 | 38 |

| 10 | PARTITION LIST ALL | | 46M| 977M| 631K (2)| 02:06:19 | 1 | 22 |

| 11 | TABLE ACCESS FULL | PRPCMAIN | 46M| 977M| 631K (2)| 02:06:19 | 1 | 836 |

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

Predicate Information (identified by operation id):

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

5 - access("PRPJPAYREC"."RECEIPTNO"=:1)

7 - access("PRPJREFREC"."RECEIPTNO"=:1)

这个sql的问题是ab表没有关联,造成笛卡尔积(执行计划中的MERGE JOIN CARTESIAN),b表是8KW数据量10G多的大表,做笛卡尔积的资源需求无法满足。这个sql是导致频繁报错的罪魁。

两个sql修改如下:

增加表关联

select a.riskcode,

/*省略部分*/

b.comcode as comcodey

/*省略部分*/

from (select *

from ccic.prpjpayrec

union all

select * from ccic.prpjrefrec) a,

ccic.PrpCmain b

where a.policyno = b.policyno

and a.receiptno = :1;

执行计划

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

| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |

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

| 0 | SELECT STATEMENT | | 2 | 426 | 4 (0)| 00:00:01 | | |

| 1 | NESTED LOOPS | | 2 | 426 | 4 (0)| 00:00:01 | | |

| 2 | VIEW | | 2 | 336 | 2 (0)| 00:00:01 | | |

| 3 | UNION-ALL | | | | | | | |

| 4 | TABLE ACCESS BY INDEX ROWID | PRPJPAYREC | 1 | 167 | 1 (0)| 00:00:01 | | |

|* 5 | INDEX UNIQUE SCAN | PK_JPAYREC | 1 | | 1 (0)| 00:00:01 | | |

| 6 | TABLE ACCESS BY INDEX ROWID | PRPJREFREC | 1 | 160 | 1 (0)| 00:00:01 | | |

|* 7 | INDEX UNIQUE SCAN | PK_JREFREC | 1 | | 1 (0)| 00:00:01 | | |

| 8 | TABLE ACCESS BY GLOBAL INDEX ROWID| PRPCMAIN | 1 | 45 | 1 (0)| 00:00:01 | ROWID | ROWID |

|* 9 | INDEX UNIQUE SCAN | PK_CMAIN | 1 | | 1 (0)| 00:00:01 | | |

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

Predicate Information (identified by operation id):

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

5 - access("PRPJPAYREC"."RECEIPTNO"=:1)

7 - access("PRPJREFREC"."RECEIPTNO"=:1)

9 - access("A"."POLICYNO"="B"."POLICYNO")

使用绑定变量

select count(1)

from (select *

from ccic.prpjrecdetail

where receiptno = '"+iReceiptno+"'

union all

select *

from ccic.prpjrecdetailhis

where receiptno = '"+iReceiptno+"');

1

使用temp表空间的操作

1.临时表的操作

2.Hash Join

3.Sort-Merge joins

4.CREATE INDEX

5.ANALYZE

6.Select DISTINCT

7.ORDER BY

8.GROUP BY

9.UNION

10.INTERSECT

11.MINUS

12.etc.

2

官方文档对direct path read/write temp事件的解释

direct path read and direct path read temp

When 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

direct path write and direct path write temp

When a process is writing buffers directly from PGA (as opposed to the DBWR writing them from the buffer cache), the process waits on this event for the write call to complete. Operations that could perform direct path writes include when a sort goes to disk, during parallel DML operations, direct-path INSERTs, parallel create table as select, and some LOB operations.

Like direct path reads, the number of waits is not the same as number of write calls issued if the I/O subsystem supports asynchronous writes. The session waits if it has processed all buffers in the PGA and is unable to continue work until an I/O request completes.

Check the following V$SESSION_WAIT parameter columns:

P1 - File_id for the write call

P2 - Start block_id for the write call

P3 - Number of blocks in the write call

后记

昨日我失去了自己的孩子,谨以此文悼之,愿你的灵魂步入天堂。望工作能分散我的注意力,一切还是要向前看吧。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/21129591/viewspace-1058115/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/21129591/viewspace-1058115/

Oracle 19.17升级后视图查询卡死?ASM IOdirect path write temp问题排查实录 本文详细记录了Oracle 19.17升级后视图查询卡死问题的排查过程,重点分析了ASM IOdirect path write temp等待事件。通过10046 trace文件解读、临时表空间写入分析ASM存储层性能调优,最终定位到优化器特性变更导致的执行计划问题,并提供了临时回退方案与长期优化建议。 阅读详情

相关推荐

【达梦8】vm 虚拟机centos 7 安装达梦8 数据库(单节点 主从结构)

更新:2024-04-24 17:06:00

张小三的博客 5667

近期整理(二)--pga,sga设置问题的两个诊断案例

案例1:关键词:direct path write temp这是开发人员反馈的问题:有个程序查询差不多需要返回20多万个对象,在DEVSIT都没问题,但在pre-production就跑不出来开始以为这个库没跑dbms_sta...

cla37092的博客 339

10.3.4 direct path read and direct path read temp

10.3.4 direct path read and direct path read temp 当一个会话是从磁盘读buffer 直接到PGA(相对于buffer cache 在SGA), 它在这个事件上 如果I/O 子系统不支持异步I/Os, 那么每个等待对应物理读请求。 如果 I/O 子系统支持异步I/O, 然后处理是可以 重叠执行度请求处理blocks 在PGA里。 当处理

zhaoyangjian724的专栏 484

oracle等待事件10——I/O上的等待事件 下篇

5、direct path read temp / direct path write temp 为了排序工作在临时区域读写时,等待direct path read tempdirect path write temp事件。这个等待时间是从10g开始被分类的。9i之前是通过direct path readdirect path write 等特观察的。排序段上的direct path I/

changyanmanman的专栏 4527

direct path read/read temp等待事件

当会话从磁盘直接读取数据块到PGA(绕过SGA)时,发生direct path read/read temp等待事件 ,下图简要描述了这种方式的读取方式: 如果I/O子系统不支持异...

ckm9894的博客 1011

Oracle 11g direct path read 等待事件的理解

在Oracle 11g中,全表扫描可能使用direct path read方式,绕过buffer cache,这样的全表扫描就是物理读了。 在10g中,都是通过gc buffer来读的,所以不存在direct path read的问题。   direct path read较高的可能原因有:   1. 大量的磁盘排序操作,order by, group by, union, distinct,

guxueliang的专栏 4871

oracle等待事件-direct path read/write

转://http://blog.chinaunix.net/uid-23177306-id-2531235.html 一、direct path read1、与直接读取相关联的等待事件。当ORACLE将数据块直接读入会话的PGA(进程全局区)中,同时绕过SGA(系统全局区)。PGA中的数据并不其他的会话共享。即表明,读入的这部分数据该会话独自使用,不放于共享的SGA中。 2、在排序操作(or...

weixin_33725272的博客 198

direct path read temp等待事件

Often related to sorting operations, check to see if occurring primarily in temp tablespaces. Solutions 1) Reading from temp tablespaces If the database parameter workarea_size_policy = AUTO: Incr...

weixin_33949359的博客 112

oracle回滚等待事件,oracle等待事件3构造一个Direct Path write等待事件构造一个Log File Sync等待事件...

第一篇 《oracle等待事件1分别用表索引上数据的访问来产生db file scattered read等待事件》http://leonarding.blog.51cto.com/6045525/1105411第二篇 《oracle等待事件2构造一个DB File Sequential Read等待事件构造一个Direct Path Read等待事件》http://leonarding.bl...

weixin_34697393的博客 207

通过等待事件学习Oracle 体系结构:(二)谈谈PGA临时表空间

三、通过direct path read/writetemp谈谈PGA临时表空间: 官方描述: When a process is wr...

cuiruipan6325的博客 348

oracle等待事件3构造一个Direct Path write等待事件构造一个Log File Sync等待事件

第一篇 《oracle等待事件1分别用表索引上数据的访问来产生db file scattered read等待事件》http://leonarding.blog.51cto.com/6045525/1105411 第二篇 《oracle等待事件2构造一个DB File Sequential Read等待事件构造一个Direct Path Read等待...

weixin_33698043的博客 108

AWR报告中10大“异常等待事件”,破局之道!

等待事件是DBA与数据库的对话——听懂它的语言,才能驯服性能猛兽,评论区分享你的经验,拯救那些正在熬夜看AWR报告的同行!

IT邦德 1048

Oracle数据库压测利器SLOB:原理、部署与性能瓶颈分析实战

数据库性能评估与容量规划领域,基准测试(Benchmark)是衡量系统处理能力、发现潜在瓶颈的核心手段。其原理在于通过模拟特定负载模型,对数据库的I/O、CPU、内存等子系统施加可控压力,从而量化性能指标。对于Oracle数据库而言,物理I/O(Physical I/O)性能,尤其是随机读写延迟与吞吐量,是评估存储子系统与数据库缓存机制有效性的关键技术价值点。这直接关系到在线事务处理(OLTP)系统在高并发场景下的响应能力与稳定性。SLOB(Silly Little Oracle Benchmark)正是

weixin_30832405的博客 407

Oracle数据库入门实战:从安装配置到基础操作与数据迁移

数据库作为企业信息系统的核心,其核心功能在于高效、安全地存储与管理结构化数据。其工作原理基于客户端-服务器架构,通过SQL语言进行交互,并利用事务、锁机制等保证数据一致性。掌握数据库技术对于构建稳定可靠的业务系统具有重要价值,广泛应用于金融、电商、政务等关键领域。在实际工程实践中,**Oracle数据库**的安装配置、用户权限管理以及**数据迁移**是开发者常面临的基础挑战。本文将以Oracle为例,系统讲解在Windows环境下的安装避坑指南、基础SQL操作、用户与表空间管理,并深入探讨如何将数据迁移至M

weixin_30784501的博客 325

linux安装mysql ndb cluster

本文介绍了在CentOS 6.9系统上安装MySQL NDB Cluster 7.5.17的准备工作及核心概念。主要内容包括: 版本信息 操作系统:CentOS 6.9 x86_64 MySQL NDB Cluster版本:7.5.17 提供了官方下载链接校验值 NDB Cluster核心组件 数据节点(Data Node):存储实际数据 SQL节点(SQL Node):提供数据访问接口 管理节点(Management Node):负责集群管理 关键技术特性 事件日志系统记录集群活动 检查点机制确保数据持

OceanWaves1993的博客 739

Oracle direct path write tempdirect path read temp引起的效能问题

User报告系统很慢,top提示load average一度超40+,cpu利用率很高 vmstat看上去IO很重,但是cpu wa值很低 查看top事件,发现dblink位列第一,停掉dblink也没能解决问题 select EVENT,sum(time_waited) EVENT_COUNTS from dba_hist_active_sess_history WHERE to_char(sample_time,‘YYYY-MM-DD’)=‘2022-04-04’ AND session_state

weixin_43230594的博客 1251
上一篇: exp/imp(3)注意事项
下一篇: exp/expdp遭遇ORA-00600: internal error code, arguments: [qmtInit1]
congbu2215
博客等级 码龄10年 0粉丝 0原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值