zoukankan      html  css  js  c++  java
  • 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.hashvalue=su.sqlhash and s.address=su.sqladdr
    order by se.username,se.sid
     
  • 相关阅读:
    二:虚拟游戏摇杆
    一:AndEngine的小例子
    打造属于自己的安卓Metro界面
    linux设备驱动第四篇:驱动调试方法
    C# 二叉查找树实现
    初识 Angular 体会
    C# 霍夫曼二叉树压缩算法实现
    TypeScript笔记[5]泛型+Dictionary 转
    Axiom3D学习日记 5.Frame Listeners, and Input Handling
    Axiom3D学习日记 4.地形,天空,雾
  • 原文地址:https://www.cnblogs.com/seasonzone/p/7209950.html
Copyright © 2011-2022 走看看