Home > Database > Mysql Tutorial > body text

Oracle 临时表空间过大问题解决

WBOY
Release: 2016-06-07 16:53:15
Original
1014 people have browsed it

查询Oracle数据库服务器时,发现数据库服务器磁盘使用空间达到了98%,分析总共的数据文件也不可能达到如此大,经过查询发现原来

    查询Oracle数据库服务器时,发现数据库服务器磁盘使用空间达到了98%,分析总共的数据文件也不可能达到如此大,经过查询发现原来临时表空间的使用情况达到了 32G,导致磁盘空间使用紧张。搜索了相应的文档与资料后,查出临时表空间主要使用在:

    - 索引创建或重创建。

    - ORDER BY or GROUP BY (这个是‘罪魁祸首’)

    - DISTINCT 操作。

    - UNION & INTERSECT & MINUS - Sort-Merge joins. - Analyze 操作

    - 有些异常将会引起temp暴涨(这个也很有可能)

    下面是重新创建一个临时表空间,把原来的默认临时表空间drop掉(包括里面的临时数据文件)再重新建立

SQL> create temporary tablespace temp2
2 tempfile '/home/oracle/oracle/product/10.2.0/oradata/hatest/temp02.pdf' size 512M reuse
3 autoextend on next 640k maxsize unlimited;

Tablespace created.

SQL> alter database default temporary tablespace temp2;

Database altered.

SQL> drop tablespace temp including contents and datafiles;

Tablespace dropped.
(注意:由于临时表空间的数据文件比较大,所以这步可能会花费比较长的时间)
SQL> create temporary tablespace temp
2 tempfile '/home/oracle/oracle/product/10.2.0/oradata/hatest/temp01.pdf' size 512M reuse
3 autoextend on next 640K maxsize unlimited;

Tablespace created.

SQL> alter database default temporary tablespace temp;

Database altered.

SQL> drop tablespace temp2 including contents and datafiles;

Tablespace dropped.

SQL> exit


    以上的方法只是暂时释放了临时表空间的磁盘占用空间,是治标但不是治本的方法,,真正的治本的方法是找出数据库中消耗资源比较大的sql语句,然后对其进行优化处理。下面是查询在sort排序区使用的执行耗时的SQL

Select se.username,se.sid,su.extents,su.blocks*to_number(rtrim(p.value))as Space,tablespace,segtype,sql_text
from v$sort_usage su,v$parameter p,v$session se,v$sql s
where p.name='db_block_size' and su.session_addr=se.saddr and s.hash_value=su.sqlhash and s.address=su.sqladdr
order by se.username,se.sid

linux

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!