Reclaiming space on Tables, Indexes,Lob Index,Lob Partition, Lob Segments

Hi,

  There is a big database and we are having issues with space.     I want to reclaim unused space from  segments.

  a) What query can i perform that shows unused space of segments ?

  b)  I will like to know  how to reclaim unused space from these different type of segments :Tables, Indexes,Lob Index,Lob Partition, Lob Segments.

 c) How to reclaim space from LOB Columns.

Thanks.
LVL 1
joe_echavarriaDatabase AdministratorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sdstuberCommented:
a select * from dba_free_space

b you can try to resize your data files, but if you have segments at the end of a file you can't shrink them beyond the last block of that segment

The usual way of reclaiming space is to move the objects at the end of a data file into a different tablespace.  Then shrink the datafile.  You can optionally move the objects back after the shrink and then drop the "holding" tablespace once it's empty, or just leave them there.  There's no technical advantage either way, it's more of an administrative convenience and your own internal standards.


c same as b
joe_echavarriaDatabase AdministratorAuthor Commented:
What about the below commands ?

ALTER TABLE  lob_test modify lob (data) (shrink space);

ALTER TABLE &table_name SHRINK SPACE CASCADE;

ALTER TABLE &table_name> LOB (&lob_column) (SHRINK SPACE;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sdstuberCommented:
within an object,  yes, you can do that.

but.. that doesn't make your tablespace any smaller, so your database will still be just as big as it was before hand.

To use an analogy, if you have a 1 gallon bucket full of water and then you pour some of the water out, the water had "shrunk" but the bucket is still the same size.

But continuing the analogy - you now have more space in the bucket to add more water.
Same with a tablespace, if you shrink the objects within it, then you can grow those objects again, or add more objects.  The tablespace is still the same size.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

joe_echavarriaDatabase AdministratorAuthor Commented:
But having the less data in the tablespace might help us to improve some performance ?
johnsoneSenior Oracle DBACommented:
Shrinking the free space of objects isn't going to improve performance.

The only case where that would help is if you are doing full table scans and have lots of deletes and there is a large amount of space below the high water mark that is being scanned.
sdstuberCommented:
It "can" help, but usually not by much.

If you have  1000 rows of data spread across 1000 data blocks, then you'll need to read 1000 data blocks to get your data (full table scan or index read, maybe even more with full table scan)

If you shrink your data down to fewer blocks (i.e. more rows per block) then it requires fewer reads.

Full table scans as mentioned above are a particularly bad case because you'll read through empty blocks en route to finding data blocks.  

Index scans are at least guaranteed to point to "some" data", but you still might end up reading more blocks than necessary if those blocks have lots of free space in them.
DavidSenior Oracle Database AdministratorCommented:
I've been thinking about your original comment, "issues of space".  While the advice provided is from the best, I wonder if this is addressing your performance concern.  

For example, what evidence has led you to deduce there's a problem.  This could be something like your file systems are full; or there is a rise in I/O wait time; or there are years upon years of obsolete data; or the users perceive that interactive queries are taking longer than usual.

So please say more, if you can .
joe_echavarriaDatabase AdministratorAuthor Commented:
I have shrinking space and performance have improved a lot.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.