Home > Database > Mysql Tutorial > body text

如何找出引起ORA-1652的SQL

WBOY
Release: 2016-06-07 16:18:38
Original
1122 people have browsed it

Wed Aug 20 17:16:37 2008 ORA-1652: unable to extend temp segment by 128 in tablespace DBA_TEMP 要解决这个问题,我们首先要导致这个问题的SQL,可能方法有几种: 1、设置events alter system set events '1652 trace name errorstack level 1'; 这种方

Wed Aug 20 17:16:37 2008
ORA-1652: unable to extend temp segment by 128 in tablespace DBA_TEMP

要解决这个问题,我们首先要导致这个问题的SQL,可能方法有几种:

1、设置events

alter system set events '1652 trace name errorstack level 1';

这种方法有一定局限:

1)它不能获取已发生的1652的错误信息,只能对以后出现1652错误时生成一个trace文件;

2)用events,不清楚会对数据库有什么不好的影响。

2、查询V$SQL视图:

如select * from v$sql order by direct_writes/executions desc;

这种方法的局限性是:

1)因为很难知道V$SQL视图中的SQL执行时间,难以确认具体是那个SQL导致错误的

2)引起问题的SQL极有可能已经被age out了

3、 生成错误发生时的awr、statspack报表,从报表中的SQL ordered by Reads部分找出SQL

这种方法更不可靠,,因为:

1) SQL ordered by Reads读写的不一定是临时表空间

2) awr/statspack报表是根据物理读的总量排序的,如果导致问题的SQL执行次数少,那也是不会出现在这些报表中的。

4、查询awr相关视图

对于10G来说,这种方法是最可行、最准确的。

SELECT DISTINCT TO_CHAR(SUBSTR(b.sql_text,1,4000))
FROM sys.WRH$_SQLTEXT b
WHERE b.sql_id IN
(SELECT sql_id
FROM
(SELECT a.sql_id
FROM sys.WRH$_SQLSTAT a
WHERE a.parsing_schema_name NOT IN ('SYS')
AND a.executions_total >0
AND a.direct_writes_total >0
AND a.SNAP_ID IN
(SELECT SNAP_ID
FROM sys.WRM$_SNAPSHOT
WHERE to_date('2008:08:20 17:20:08','yyyy:mm:dd hh24:mi:ss') BETWEEN begin_interval_time AND end_interval_time
)
ORDER BY a.direct_writes_total/ a.executions_total DESC
)
WHERE rownum );

基本上,结果中的第一句只要不是insert /*+ append */之类的语句,那么它就极有可能是导致ORA-1652的SQL。

如果是9i,用statspack,也可以用类似的SQL从statspack视图查到需要的结果。


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!