Skip to Main Content
  • Questions
  • Space Fragmentation in a table which has only inserts

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, praveen.

Asked: August 05, 2018 - 7:31 am UTC

Last updated: August 22, 2018 - 2:22 am UTC

Version: 11.2

Viewed 1000+ times

You Asked

Hi Tom,

This is Praveen.

1)I have table x which has only inserts in it and updates rarely,so my doubt is till now i have heard and read that there will be space fragmentation for delete operation done on a table and i couldn't find out how the insert statement,update statements for table causes space fragmentation.So please explain this briefly.
2) I have a table y which stores the images.The size of this table(along with size of lob segment) is approx 8TB,out of 8TB table size is approx 1TB and the lob segment size is 7TB. Now if i delete approx 700Gb of table data,then to reclaim the space of the lob segment there is a command which i have seen i.e ALTER TABLE table_name MODIFY LOB(lob_column) (SHRINK SPACE), But if i run this on 7tb of lob segment it hasn't come out even after 5 to 6 hrs .
Note:My table y here is using pctversion value of 10
3)I have read that the space in the lob segments will be reused based on the parameter(retention or pctversion),so in my case if i delete 10% of lob segment(i.e approx 700gb of data) size, will the next coming insert statements reuse the space in the lob segment as the pctversion parameter specifies 10% of the total lob segment space to be used as undo for lob and it overwrites them when they exceed the 10% of the lob segment space.

So please suggest me the correct method to reclaim the space in the lob segments and also regd the insert statement causing fragmentation


Thanks.

and Connor said...

1) What makes you think there is fragmentation in an insert only table? There will be *some* small holes here in there assuming your are using an ASSM tablespace, but nothing that would typically be any cause for concern. You havent provided any context or data showing fragmentation so I can't really comment more than that.

2) Your statement can be interpreted a couple of ways here. Is that 700G of the 1TB of table data, or 700G of the entire 8TB. If I was deleting 700G of table data out of 1TB, I'd be looking at a CTAS rather than a delete. In the latter instance, maybe a delete is your only option.

pctversion does not reclaim space - it simply defines how much of lob space is retained for old versions of lob data to provide consistent read. If you are doing your deletes during a very quiet time, you could potentially reduce this, but the parameter is governing when space holding stale lob data can be reused.

If you are using securefiles, then the database should take care of the balance between space usage and reclamation for you. See this post for some examples

https://asktom.oracle.com/pls/apex/asktom.search?tag=reclaimreuse-lob-space

3) see above. pctversion effectively says if your lob data is "x" in size, then we will grow the segment up to x + 10% to handle consistent read before we start reusing deleted space.

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Praveen, August 20, 2018 - 11:19 am UTC

As mentioned in my above question ,
we have table x with BLOB column which stores pictures,has lobsegment size of 7.7 TB and table datasize 800 GB .
i would like to delete 7 cr records (10 % of total table count ) from table x and insert them into another table Z.
We are facing following challenges :
1.Insertion is slow ( we tried append hint - insert /*+ append */ into z select * from x , we also tried using forall , we tried table z with nologging , disable storage in row(as lob column data is more than 4000bytes) )
Kindly suggest any approach to tune insertion .
2. In Table x blob column is with PCTVERSION 10 and lob is stored as basic file .
we are deleting apprx 7 cr records from x table equilvalent to almost 700 GB which is 10% of total lobsegment size . so to store the undo it will use some amount of space in table x lobsegment (inside lobsegment ).
3.After this deletion there won't be any update and delete's on this table (table x) in future , only select and insert will come on this table . So clarify till how much time that undo data(genrated during deletion ) will be stored in lobsegment and space will get reuse .
4.As we are deleting approx 7 cr records (equivalent to 700 GB size ) from table x , To reclaim space after deletion we have used this query ->>ALTER TABLE x MODIFY LOB (image) (SHRINK SPACE) ; . we have executed this query and it was running for more than 6 to 8 hrs . so we can't implement it on production .
so Kindly suggest any alternative approach to reclaim the space .
Note : We have tried to replicate this scenario by creating a small table with lob segment size as (approx 30GB) with pctversion as 10 and storage of lob as basic file .In this scenario,we have observed that after deleting the data (approx 10% of the total lob size) space was getting reused when we tried to insert.
Connor McDonald
August 22, 2018 - 2:22 am UTC

I see this has come in as a new question - we'll take it from there.

More to Explore

Administration

Need more information on Administration? Check out the Administrators guide for the Oracle Database