how to release the storage when truncating the partition [message #555692] |
Sun, 27 May 2012 07:10  |
kashifchughtai
Messages: 125 Registered: October 2007
|
Senior Member |
|
|
hi guys,
my assuption is that when we truncate the partition it immediatly release the allocatd storage.
i have just tested the scenario , but still i can see that table size is same even after truncating the partition( which have around 25% of the data)
can you please tell if my assumption is right?
alter table test truncate partition t1p3 update indexes ;
OR
alter table test truncate partition t1p3 drop storage update indexes ;
to see the table size:
SELECT owner, table_name, TRUNC(sum(bytes) / 1024 / 1024) Meg
FROM (SELECT segment_name table_name, owner, bytes
FROM dba_segments
WHERE segment_type = 'TABLE'
UNION ALL
SELECT i.table_name, i.owner, s.bytes
FROM dba_indexes i, dba_segments s
WHERE s.segment_name = i.index_name
AND s.owner = i.owner
AND s.segment_type = 'INDEX'
UNION ALL
SELECT l.table_name, l.owner, s.bytes
FROM dba_lobs l, dba_segments s
WHERE s.segment_name = l.segment_name
AND s.owner = l.owner
AND s.segment_type = 'LOBSEGMENT'
UNION ALL
SELECT l.table_name, l.owner, s.bytes
FROM dba_lobs l, dba_segments s
WHERE s.segment_name = l.index_name
AND s.owner = l.owner
AND s.segment_type = 'LOBINDEX')
WHERE owner ='OWNER'
and table_name= 'TEST'
GROUP BY table_name, owner
HAVING SUM(bytes) / 1024 / 1024 > 10
ORDER BY SUM(bytes) desc
regards,
kashif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: how to release the storage when truncating the partition [message #555712 is a reply to message #555707] |
Sun, 27 May 2012 10:05   |
Solomon Yakobson
Messages: 3305 Registered: January 2010 Location: Connecticut, USA
|
Senior Member |
|
|
kashifchughtai wrote on Sun, 27 May 2012 10:54@BLACKSWAN: are you sure it returns the space back to tablespace , i dont see any increase in tablespace after deleting the partition? idealy it should have increased?
Why should it? Think about what is "returned back". Extents, previously occupied by table segment are simply marked as free. So nothing happens to datafile file size on OS level.
kashifchughtai wrote on Sun, 27 May 2012 10:54
@John Watson: i missed it, but how it confusing the issue?
Since you are truncating partition, your table is partitioned table. Therefore, there will be no TABLE type segments for it. Segement type will be TABLE PARTITION. Same way for partitioned indexes segment type will be INDEX PARTITION. So your query doesn't measuse size correctly and you can't make any conclusions based on it.
SY.
|
|
|
|