楼主: szbestway

一块来分析temp表空间不能被释放的问题!

[复制链接]
论坛徽章:
1
授权会员
日期:2005-10-30 17:05:33
21#
 楼主| 发表于 2001-11-23 15:58 | 只看该作者
非常感谢各位,由于周末数据库的压力太小,可能无法观测出有效的值,我会在星期一提供高峰时的数据,再讨论!!!

使用道具 举报

回复
论坛徽章:
3
ITPUB元老
日期:2005-02-28 12:57:00授权会员
日期:2005-10-30 17:05:33会员2006贡献徽章
日期:2006-04-17 13:46:34
22#
发表于 2001-11-23 17:38 | 只看该作者
嗯,我在想,空间虽然可能如你猜测可能会无限制增长,但你也不妨试一下,给它10G多空间,是不是也一下子用完,或者尽可能再多一点。试试无妨。试试看~~

使用道具 举报

回复
论坛徽章:
2
ITPUB元老
日期:2005-02-28 12:57:00授权会员
日期:2005-10-30 17:05:33
23#
发表于 2001-11-24 20:46 | 只看该作者
db_block_size=4k,你重建了库?

使用道具 举报

回复
论坛徽章:
2
授权会员
日期:2005-10-30 17:05:33ITPUB9周年纪念徽章
日期:2010-10-08 09:28:51
24#
发表于 2001-11-25 08:44 | 只看该作者
我个人觉得白鹭的观点很好,其实如果你不shutdown数据库,temp表空间仍然有
扩大的可能,还要看sort_area_size_retained的大小,其实,如果空间有的多,
可以再建几个temp表空间,然后对一些复杂事务单独给一个表空间,比如你
诉说的存储过程,同时sql也有必要优化,实在不行,再建一个表空间后把特大的这个删掉

使用道具 举报

回复
论坛徽章:
1
授权会员
日期:2005-10-30 17:05:33
25#
发表于 2001-11-25 21:27 | 只看该作者
Try this method:
SVRMGRL>alter tablespace temp default storage(pctincrease 1);
SVRMGRL>alter tablespace temp default storage(pctincrease 0);

tell me this one work or not.

使用道具 举报

回复
论坛徽章:
47
蒙奇·D·路飞
日期:2017-03-27 08:04:23马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11一汽
日期:2013-09-01 20:46:27复活蛋
日期:2013-03-13 07:55:232013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-09 18:03:322012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:20
26#
发表于 2001-11-26 05:47 | 只看该作者
I dont' see any problem in your v$sort_segment. Why do you worry about temp extents not freed? They're not supposed to if they're in the TEMP tablespace (whose contents are 'TEMPORARY'). Current_users 374 sounds like a very busy database. Did you query v$sort_usage while you queried v$sort_segment? To tune sort_area_size, you may want to check sort (memory) and sort (disk) statistics. That's better than blindly setting the sort area parameters. Also, I usually set sort_area_retained_size to half sort_area_size.

Nevertheless, tuning SQLs always gives you the most benefit unless all your heavily used SQLs are already well tuned.

Yong Huang

最初由 szbestway 发布
[B]这是昨天temp表空间已经剩余100M左右,并且不变化是做的查询!

select * from sys.v_$sort_segment;
---
ABLESPACE_NAME                 SEGMENT_FILE SEGMENT_BLOCK EXTENT_SIZE
------------------------------ ------------ ------------- -----------
URRENT_USERS TOTAL_EXTENTS TOTAL_BLOCKS USED_EXTENTS USED_BLOCKS FREE_EXTENTS
------------ ------------- ------------ ------------ ----------- ------------
REE_BLOCKS ADDED_EXTENTS EXTENT_HITS FREED_EXTENTS FREE_REQUESTS   MAX_SIZE
---------- ------------- ----------- ------------- ------------- ----------
AX_BLOCKS MAX_USED_SIZE MAX_USED_BLOCKS MAX_SORT_SIZE MAX_SORT_BLOCKS
--------- ------------- --------------- ------------- ---------------
ELATIVE_FNO

TEMP                                       8        244977        1024
          374           448       459140          374      383308           74
      75832           448         976             0             0        448
    459140           448          459140             1            1029
           8 [/B]

使用道具 举报

回复
论坛徽章:
3
ITPUB元老
日期:2005-02-28 12:57:00授权会员
日期:2005-10-30 17:05:33会员2006贡献徽章
日期:2006-04-17 13:46:34
27#
发表于 2001-11-26 12:58 | 只看该作者
1. sort_area_size 应该有你的应用来决定,不是oracle support,
标准:
select  name, value
  from  v$sysstat
where  name = 'sorts (disk)'
    or  name = 'sorts (memory)';
memory/disk > 99%
2。sort_area_retained_size =0 不是个很好的选择,如果的数据库是MTS,可以用 sort_area_size/2, 方正我是一直然他=sort_area_size,这不会对你的内存长生太大的影响。
3。强烈建议使用 local managed temporary tbs, 你做过
shutdown吗?像你这个数据库如果不用 local managed tbs,shutdown会把你搞死,
4。正如前面各位所说,不要担心,你的应用需要这么大的temp
tbs,你只有增加它,而且达到一定的程度它会稳定下来。
5。调整应用是个很好的主意,不过我已经提了999回了,也没见公司有行动。
6。如果不用local managed tbs ,主意经常做
alter tablesapce xxx coalesce, I am just doing it!

使用道具 举报

回复
论坛徽章:
1
授权会员
日期:2005-10-30 17:05:33
28#
发表于 2001-11-26 13:01 | 只看该作者
看看也許有用
   


SMON - Temporary Segment Cleanup and Free Space Coalescing in Oracle 7.3 and
Higher

PURPOSE
~~~~~~~

  Since the introduction of the unlimited extents feature in Oracle 7.3, it is
  possible for SMON to have to either clean up a large number of temporary
  extents, or to coalesce a large number of free extents. This can manifest
  itself by SMON appearing to spin, consuming a high percentage of CPU for
  long periods. This article explains what is happening, and what (if
  anything) can be done.

  The discussion concentrates mainly on non-TEMPORARY type tablespaces. There
  is however a section at the end of the article which discusses possible
  issues with tablespaces of type TEMPORARY.

SCOPE & APPLICATION
~~~~~~~~~~~~~~~~~~~
  This article is intended to assist DBAs encountering SMON appearing to spin
  and consume high percentages of CPU by providing an understanding of the
  issues.

RELATED DOCUMENTS
~~~~~~~~~~~~~~~~~
  [NOTE:35513.1] Removing `stray` TEMPORARY Segments
  [NOTE:50592.1] Extent Sizes for Sort, Direct Load and Parallel Operations
  [NOTE:65973.1] Temporary Tablespaces and the Sort Extent Pool
  [NOTE:68836.1] How to efficiently drop a table with many extents

What to look for
~~~~~~~~~~~~~~~~
  The most common indicator is the SMON process consuming large amounts
  of CPU for a long period. UNIX O/S utilities sar or vmstat will show how busy
  CPU(s) are; ps will show which process is using the CPU.

What is SMON doing
~~~~~~~~~~~~~~~~~~
  Once you have identified that SMON is using lots of CPU, you need to
  identify whether it is performing temporary segment (extent) cleanup, or
  free space coalescing.

Free space coalescing
~~~~~~~~~~~~~~~~~~~~~
  When does SMON coalesce?

    o. SMON wakes itself every 5 minutes and checks for tablespaces with
       default pctincrease != 0.

  How to identify whether SMON is coalescing

    o. Check whether there are a large number of free extents that might
       be being coalesced by running the following query a few times:

         SELECT COUNT(*) FROM DBA_FREE_SPACE;

       If the count returned is dropping while SMON is working, it is
       likely that SMON is coalescing free space.

  What are the effects on the database?

    o. Because SMON acquires the Space Transaction (ST) enqueue in
       exclusive mode, other processes requiring the enqueue will be
       blocked. This is typically manifested by multiple <oerr:ORA-1575>
       errors.
    o. SMON sits in a very tight loop while coalescing, and consumes close
       to 100% CPU. If the system is CPU-bound, the run queue will increase
       as other processes try to get onto CPU.

  Can anything be done to stop SMON grabbing CPU?

    o. If there is no CPU contention, and no processes being blocked because
       of failure to acquire the ST enqueue, DO NOT DO ANYTHING. Leave SMON
       to complete the coalescing.

       THE DATABASE CAN BE SHUTDOWN CLEANLY WITH UN-COALESCED EXTENTS. If SMON
       is performing the coalesce, a shutdown will NOT undo the work completed
       so far.

    o. Use the 'alter tablespace <tbs name> coalesce' command. This is quicker
       than SMON, and the work is performed in in fewer space transactions, and
       therefore makes fewer enqeueue acquisitions. HOWEVER, IF THE COMMAND IS
       INTERRUPTED, ALL ITS COALESCING WORK WILL BE LOST.

    o. It is possible to force a user session to coalesce free extents. See
       Note 35513.1 for details. Again, quicker than SMON. HOWEVER, IF THIS
       OPERATION IS INTERRUPTED, ALL IT'S COALESCING WORK WILL BE LOST.

    o. Offlining the tablespace/datafiles containing the extents to be
       coalesced has NO effect.

Temporary segment cleanup
~~~~~~~~~~~~~~~~~~~~~~~~~

  When does SMON cleanup temporary segments?

    o. Typically a user process allocates a temporary segment (multiple
       extents) and then dies before cleaning them up, or the user process
       receives an error causing the statement to fail. SMON is posted to do
       the cleanup. In addition, actions like CREATE INDEX create a
       temporary segment for the index, and only convert it to permanent
       once the index has been created. Also, DROP <object> converts
       the segment to temporary and then cleans up the temporary segment.

    o. During normal operations, user processes that create temporary segments
       are responsible for cleanup.

  How to identify whether SMON is cleaning up temporary extents

    o. Check whether there are a large number of temporary extents that might
       be being cleaned up by running the following query a few times:

         SELECT COUNT(*) FROM DBA_EXTENTS WHERE SEGMENT_TYPE='TEMPORARY';

       If the count returned by the above query is dropping while SMON is
       working, it is likely that SMON is performing temp segment cleanup.
       See section 'Tablespaces of type TEMPORARY' for more details on
       this.

  What are the effects on the database?

    o. Again, SMON will continually acquire and then release the ST enqueue
       in exclusive mode. This can cause contention with other processes and
       lead to <oerr:ORA-1575> errors.

    o. CPU utilization is not exceptionally high. During tests, SMON
       consumed between 10% and 20% CPU during cleanup, and so this operation
       has less impact than coalescing, as far as SMON is concerned.
       Furthermore, SMON performed the cleanup in 'chunks', cleaning up a
       subset of the extents at a time.
      

  Can anything be done to stop SMON grabbing CPU?

    o. Not a great deal. As with coalescing, if there is no CPU contention,
       and no processes being blocked because of failure to acquire the ST
       enqueue, DO NOT DO ANYTHING. However because SMON does not work as hard
       cleaning up temporary extents, it should not be a big issue.
       Note: If you are using TEMPORARY type temporary tablespaces then
             SMONs cleanup of the segment can be a problem as it will not
             service sort segment requests while performing cleanup.
             See below (TEMPORARY tablespaces) for more information.

       It should be noted that a normal/immediate shutdown will not complete
       until all temporary segments have been cleaned up. Shutdown will
       'kick' SMON to complete cleanup.

    o. Offlining the tablespace/datafiles in which the extents reside has NO
       effect.

Avoidance
~~~~~~~~~

   With a little forethought and care, the above situations can be avoided:

   o. Do not create temporary tablespaces with small initial and next default
      storage parameters. Also beware of unlimited maxextents on temporary
      tablespaces.

      Note, TEMPORARY type tablespaces set maxextents unlimited automatically.
      Furthermore, the NEXT AND INITIAL extent sizes are determined from
      the default NEXT size (default INITIAL is ignored). For more details on
      temporary extent sizes, see [NOTE:50592.1].

   o. Use tablespaces of type TEMPORARY. Sort segments in these tablespaces
      are not cleaned up. This reduces contention on the ST enqueue and also
      reduces CPU usage by SMON **UNLESS** the database is shutdown and
      restarted. If TEMPORARY type tablespaces are in use then SMON will
      clean up its segments after startup following a shutdown. In this case
      large numbers of extents can be a severe problem as SMON will not
      service user "sort segment requests" until the cleanup is complete.
      If the cleanup is to take a long time users will not be able to perform
      sort operations. In this scenario you can point users at a PERMANENT
      temporary tablespace while SMON cleans up the TEMPORARY temporary
      tablespace. This is likely to cause ST enqueue contention but will allow
      users sessions to sort on disk when necessary rather then them just
      blocking.
      Eg:
           If SMON is busy cleaning up a TEMP segment containing a lot
           of extents it cannot service 'sort segment requests' from other
           sessions. Pointing the users at a PERMANENT tablespace as
           their temporary tablespace can help keep the system running
           until SMON is free again:

           CREATE TABLESPACE NEWTEMP .... (your own specification here)
           (DO NOT CREATE IT AS TYPE TEMPORARY)

           Move the users over to this:

                  select username from dba_users
                 where temporary_tablespace='TEMP';

           For each user in this list:

                alter user XXXXX temporary tablespace NEWTEMP;

           Once SMON has cleaned up the extents reset the storage clause
           on each tablespace to sensible values and you can then point
           users back at a TEMPORARY temp tablespace.

   o. Beware of creating large objects with inappropriate (small) extents. If
      the creation of the object fails, SMON cleans up. Also, dropping such an
      object will create a lot of cleanup work for the user process.

      Oracle8 ONLY. Make use of the tablespace MINIMUM EXTENT size to help
      minimise the risk of mistakes in scripts causing small extent sizes.
      This parameter ensures that every used and/or free extent size in a
      tablespace is at least as large as, and is a multiple of, this value.

      Oracle8i ONLY: It is worth considering the use of a locally managed
      temporary tablespace. This has the benefit of faster temporary segment
      cleanup after the instance has been aborted.
      Note, locally managed temporary tablespaces must be created using
      tempfile(s). Any attempt to create a locally managed temporary
      tablespace using a datafile will result in the error:
        ORA-25144: invalid option for CREATE TABLESPACE with TEMPORARY contents

使用道具 举报

回复
论坛徽章:
1
授权会员
日期:2005-10-30 17:05:33
29#
发表于 2001-11-26 13:06 | 只看该作者
Tablespaces of type TEMPORARY
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   TEMPORARY-type tablespaces were introduced in Oracle 7.3 (see [NOTE:65973.1])
   In summary:

   o. The first disk sort (after instance startup) creates a sort segment in
      the TEMPORARY tablespace.

   o. Free extents in the sort segment are re-used as required by sessions.
      
   o. The sort segment grows to a steady-state.

   o. Sort extents are not de-allocated whilst the instance is running.

   o. Permanent objects cannot be created in TEMPORARY tablespaces.

   o. There is a maximum of one sort segment per TEMPORARY tablespace.

   Thus, contention on the ST enqueue is reduced as user sessions are allocating
   and de-allocating fewer extents. Even if a user session dies, SMON will not
   de-allocate extents that the session was using for sorting.

   SMON actually de-allocates the sort segment after the instance has been
   started and the database has been opened. Thus, after the database has been
   opened, SMON may be seen to consume large amounts of CPU as it first
   de-allocates the (extents from the) temporary segment, and then when it is
   requested to perform free space coalescing of the free extents created by
   the temporary segment cleanup. Again, this behaviour will be exaggerated if
   the TEMPORARY tablespace in which the sort segment resides has inappropriate
   (small) default NEXT storage parameters (see 'Avoidance' above).

Permanent object cleanup
~~~~~~~~~~~~~~~~~~~~~~~~

   If a permanent object is made up of many extents, and the object is to be
   dropped, the user process dropping the object will consume large amounts
   of CPU in the same way as SMON does when cleaning up a temporary segment.
   Please see [NOTE:68836.1] for a discussion of this.

使用道具 举报

回复
论坛徽章:
1
授权会员
日期:2005-10-30 17:05:33
30#
 楼主| 发表于 2001-11-26 17:30 | 只看该作者

能否定个方案!

多谢各位的建议!
感谢各位! 由于今天没有时间,只好明天综合各位的建议作一下数据库的调整!
Oracle8.1.5 内存2G  SUN 2cpu

计划调整的参数:
sort_area_size =128K (原为65K)
sort_area_retained_size=128 (原为0)
由于高峰是的并发用户有700多人,因此,将sort_area_size 从计划的256K调整为128K

--使用local management
alert tablesplace temp
extent management local
uniform size 516k;

(原脚本
create tablespace temp
datafile '/datadb1/oradata/temp01.dbf' size 1024M,
'/datadb1/oradata/temp02.dbf' size 1024M,
'/datadb2/oradata/temp03.dbf' size 1024M,
'/datadb2/oradata/temp04.dbf' size 1024M,
'/datadb3/oradata/temp05.dbf' size 1024M,
'/datadb3/oradata/temp06.dbf' size 1024M
default storage( initial 4M next 4M minextents 2 maxextents 4096 pctincrease 0)
temporary;


这里不知是否需要重新创建temp表空间,
白鹭给出的脚本
(create temporary tablespace temp
tempfile '/datadb1/oradata/temp01.dbf' size 1024M,
'/datadb1/oradata/temp02.dbf' size 1024M,
'/datadb2/oradata/temp03.dbf' size 1024M,
'/datadb2/oradata/temp04.dbf' size 1024M,
'/datadb3/oradata/temp05.dbf' size 1024M,
'/datadb3/oradata/temp06.dbf' size 1024M
extent management local
uniform size 10m;
另外你要确保sort init参数设置,例如
sort_area_size =10485760 #10M
sort_area_retained_size = 0
)--tempfile 于datafile 有何不同?

我使用alter tablesapce temp coalesce
对于表空间的释放没有起到作用。

此外,前几天,将jdbc与oracle的联接数改小,temp  表空间full 的时间长了很多,用了及几天才充满!

以下是今天在高峰是的查询:
SQL> select count(*) from sys.v_$sort_usage;

  COUNT(*)                                                                     
----------                                                                     
         0                                                                     

SQL> select count(*) from dba_free_space where tablespace_name='TEMP';

  COUNT(*)                                                                     
----------                                                                     
       239                                                                     

SQL> select * from sys.v_$sort_segment;

TABLESPACE_NAME                 SEGMENT_FILE SEGMENT_BLOCK EXTENT_SIZE         
------------------------------- ------------ ------------- -----------         
CURRENT_USERS TOTAL_EXTENTS TOTAL_BLOCKS USED_EXTENTS USED_BLOCKS FREE_EXTENTS  
------------- ------------- ------------ ------------ ----------- ------------  
FREE_BLOCKS ADDED_EXTENTS EXTENT_HITS FREED_EXTENTS FREE_REQUESTS   MAX_SIZE   
----------- ------------- ----------- ------------- ------------- ----------   
MAX_BLOCKS MAX_USED_SIZE MAX_USED_BLOCKS MAX_SORT_SIZE MAX_SORT_BLOCKS         
---------- ------------- --------------- ------------- ---------------         
RELATIVE_FNO                                                                    
------------                                                                    
TEMP                                      36        197665        1024         
          783          1559      1597991          783      802579          776  
     795412          1559       39423             0             0       1559                                                                     
   1597991          1559         1597991             6            6150         
          36                                                                    
                                                                                

SQL> select * from dba_segments where tablespace_name='TEMP';

OWNER                                                                           
------------------------------                                                  
SEGMENT_NAME                                                                    
--------------------------------------------------------------------------------
PARTITION_NAME                 SEGMENT_TYPE       TABLESPACE_NAME               
------------------------------ ------------------ ------------------------------
HEADER_FILE HEADER_BLOCK      BYTES     BLOCKS    EXTENTS INITIAL_EXTENT        
----------- ------------ ---------- ---------- ---------- --------------        
NEXT_EXTENT MIN_EXTENTS MAX_EXTENTS PCT_INCREASE  FREELISTS FREELIST_GROUPS     
----------- ----------- ----------- ------------ ---------- ---------------     
RELATIVE_FNO BUFFER_                                                            
------------ -------                                                            
SYS                                                                             
                                                      
36.197665                TEMPORARY          TEMP                          
                                                           
         36       197665 6545367040    1597990       1559        4198400        
    4198400           1  2147483645            0          1               1     
          36 DEFAULT                                                            

SQL> SELECT * FROM sys.V_$SYSSTAT
WHERE NAME LIKE '%sort%';  2

STATISTIC# NAME
---------- ----------------------------------------------------------
     CLASS      VALUE
---------- ----------
       173 sorts (memory)
        64     105190

       174 sorts (disk)
        64       1751

       175 sorts (rows)
        64    9016895

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表