查询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排序区使用的执行耗时的SQLSelect 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 Oracle中暗藏的珍宝:STATSPACKUbuntu下MySQL备份与异地备份相关资讯 Oracle教程
- Oracle中纯数字的varchar2类型和 (07/29/2015 07:20:43)
- Oracle教程:Oracle中查看DBLink密 (07/29/2015 07:16:55)
- [Oracle] SQL*Loader 详细使用教程 (08/11/2013 21:30:36)
| - Oracle教程:Oracle中kill死锁进程 (07/29/2015 07:18:28)
- Oracle教程:ORA-25153 临时表空间 (07/29/2015 07:13:37)
- Oracle教程之管理安全和资源 (04/08/2013 11:39:32)
|
本文评论 查看全部评论 (0)