RE: table shrink

From: <>
Date: Wed, 9 Dec 2009 17:27:52 -0600
Message-ID: <>


When you refer to copy-keep are you referring to copying the data from my table to a temporary table and loading them back into the original table?

Thank you

Eugene Gurevich

             "Mark W. Farnham"                                             
             12/08/2009 01:16          <>,        
             PM                        <>            
                                       RE: table shrink                    


The undo required will be about:

  1. the space management changes undo from all the other things
  2. the overhead for the "block deltas" for the rows being moved
  3. the whole size of the row from the block it is “deleted” from
  4. the whole size of the row in the block it is placed in
  5. all the index updates for any row that moves.

But without examining the table details, we have no idea what fraction of the rows or total size might have to move to accomplish the shrink.

Now I don’t see any size to keep info clause in the shrink clause. What I see is:
shrink space [compact][cascade]

and a list of restrictions about when you can use it (which mostly appear related to flows that would be really complex to code and really stupid to try to do anyway.)

So I think this means you’ve purged (or are planning to purge) 40G of 41G and then do the shrink. That’s a really bad idea from the standpoint of how much work the computer has to do to accomplish the goal and how much undo you’ll need. Copy-keep the 1G to somewhere else, even if you have to make a union view to keep it continuously available if new inserts are continuing during the move. Of course if you directly address the table right now, then you’ll have a slight bump when you rename the table and create the view. If you already reference the table as an all inclusive view wrapper or a synonyn, then create or replace view or synonym will handle this for you. Sure, the database engine will have to reparse some queries, but the data will be continuously available. I think I’ve written about this before and it should be in the archives. Being able to do this thing, not the convenience of not having to drop a view or synonym before creating a different one of the same name, was the driving requirement of the Oracle VLDB advising Oracle to implement this with “breakable parse locks” in the early 1990’s and it is a shame anyone purges by delete instead of using copy-keep. Of course if you can stand an outage, you can still use copy-keep and the much cheaper direct mode. Then you can unhook the old table and dispose of it at your leisure in a mode that only has undo for the dictionary and space management changes.

Obviously be careful and test.
-----Original Message-----
From: [] On Behalf Of Sent: Monday, December 07, 2009 5:51 PM To:
Subject: RE: table shrink

Thank you, Mark

Based on the oracle's recomendation, about 1 G will be kept in the table and about 40G+ will be released. Does that this mean that the max undo I will need is 1G?

Thank you

Eugene Gurevich

For a quick rough estimate, remember that the only undo you'll get from the empty blocks is a tiny amount from the space management. It is also very unlikely that any block lower in extent order than the first empty block can
move. Finally, the total of blocks that still do have contents is a rough ceiling on the undo, so if you're keeping less than you're shrinking that is
a consideration.

If you can be out of action a bit, create table as select to keep the rows you want to retain is probably the cheapest thing unless the amount kept is greater than two times (and then measurements are required and the results vary depending on indexes, etc.) the amount to be shuffled, and you might have an opportunity to order the select so that in your destination your most frequently used access path gets the best possible cluster score and lowest cost for both the CBO and actual run time. Then of course you probably do a rename and re-index.

-----Original Message-----
From: [] On Behalf Of Adam Musch
Sent: Monday, December 07, 2009 10:58 AM To:
Subject: Re: table shrink

Remember, if it's moving rows (and therefore, changing ROWIDs), it's also got indexes to update. So it could require significantly more UNDO than the size of the table. If you can afford the downtime, you may be better off with impdp/expdp, alter table move, and/or online table redefinition.

On Mon, Dec 7, 2009 at 9:46 AM, <> wrote:
> Hello everyone:
> I am researching alter table shrink space command in before I
> it in production. According to oracle adviser, there is a table that can
> shrank
> to release over 40G of space and another which can release over 100G. I
> plan to execute the commands during a maintenance window to minimize the
> usage of these tables. I have run a small test in dev and saw that these
> command have been using undo tablespace. That tablespace is only 20G
> in my database. Does it need to match the size of the 'freeable' disk
> space, in other word do I need to increase it to about 100G? I also was
> told that
> i can cancel this command any time (in case there is a performance
> degradation) and whatever disk space has been released will stay released
> and
> I can run the command again to release the rest of the disk space. I have
> not been able to find this in any oracle documentation however. I don't
> have any table in dev to test a large shrink command.
> If anyone had any experience with this command, can you please address my
> questions on undo TS and cancelling the command please. I am
> alsowondering whether there is any downside to this operation.
> Thank you
> Eugene Gurevich
> Please consider the environment before printing this email.
> --

Adam Musch

Please consider the environment before printing this email.


Please consider the environment before printing this email. i0zX+n{+i^ Received on Wed Dec 09 2009 - 17:27:52 CST

Original text of this message