DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: Problem in deallocating unused space

  1. #1
    Join Date
    Sep 2006
    Posts
    114

    Problem in deallocating unused space

    I am trying to deallocate space within a table by adopting the following steps
    1-SQL>alter table HR_ATTENDANCE compute statistics;

    2-select avg_space, blocks, empty_blocks
    from user_tables
    where table_name ='HR_ATTENDANCE'

    AVG_SPACE BLOCKS EMPTY_BLOCKS
    ---------- ---------- ------------
    4937 180 76

    3-alter table HR_ATTENDANCE deallocate unused;

    4-alter table HR_ATTENDANCE compute statistics;
    5-repeat the step 2 and still found

    AVG_SPACE BLOCKS EMPTY_BLOCKS
    ---------- ---------- ------------
    4937 180 76
    EMPTY_BLOCKS are blocks above the HWM
    and when we use deallocate unused then empty_blocks above the HWM but i am still having unused blocks before and after deallocating unused space
    What could be the reason?
    Can anybody help me in this regard?
    thanx in advance

  2. #2
    Join Date
    Nov 2006
    Location
    Sofia
    Posts
    630
    The reason is that the empty blocks are below the HWM but they are not compacted.
    That means that when you issue Deallocate unused, it starts dealocating until an used block is met. There may be other unised blocks below the used one, but they cannot be deallocated. Look below - E means empty U means full
    EEEEUUEEEEUUUUEEEUEE| <-HWM
    So, if you start deallocating, you'll deallocate the most left 2 Es but then you meed U and can't go further.
    If you use 10g, you could do that using
    alter table T shrink space; if I am not wrong

    Regards
    Boris

  3. #3
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    Quote Originally Posted by Bore
    Look below - E means empty U means full
    EEEEUUEEEEUUUUEEEUEE| <-HWM
    So, if you start deallocating, you'll deallocate the most left 2 Es but then you meed U and can't go further.
    Boris, I think you've misunderstood how DEALOCATE UNUSED works. It frees the blocks above the HWM, not below. So in your example, not even the two rightmost (that "most left 2" in your post must be a typo, you've certaly ment "most right 2") blocks would be affected, since they are below the HWM.

    Quote Originally Posted by M.Shakeel Azeem
    EMPTY_BLOCKS are blocks above the HWM and when we use deallocate unused then empty_blocks above the HWM but i am still having unused blocks before and after deallocating unused space
    What could be the reason?
    Can you check what is the setting of the INITIAL, NEXT and MINEXTENTS for this table? It looks like your initial extent (or the combined size of your MINEXTENTS) is set to 256 blocks and if that is true, Oracle can not dealocate any space from this.
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

  4. #4
    Join Date
    Nov 2006
    Location
    Sofia
    Posts
    630
    Well, I would agree. I really messed it up. Sorry for misleading post.

  5. #5
    Join Date
    Jul 2002
    Location
    Lake Worth, FL
    Posts
    1,492

    Cool


    Oracle (8i, 9i) will de-allocate only up to the HWM or "initial extent" size whichever is first, even if the HWM is bellow this segment, try using the KEEP option with small size to find out:
    Code:
    alter table HR_ATTENDANCE deallocate unused KEEP 64k;
    Even though a small size will produce error, It will deallocate to the true HWM.

    "The person who says it cannot be done should not interrupt the person doing it." --Chinese Proverb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width