I have noticed that I have a couple of tables in our database which experienced massive inserting and deleting on a daily basis.
For example we have a table calls events_log I run this quest on that :
select segment_name Table_Name, num_rows Number_of_Rows , sum(bytes)/1024 Size_in_KB
from user_segments, user_tables
where table_name = segment_name and
segment_type = 'TABLE' and
table_name = 'EVENTS_LOG'
group by segment_name, num_rows
It shows:
TABLE_NAME NUMBER_OF_ROWS SIZE_IN_KB
EVENTS_LOG 13028 166138
I think HWM is too high. Then I try Exprt table , import it again ==> Size didn't change and unused space didn't restore!!!!
Then I try this :
create table events_log2 as select * from events_log;
truncate table events_log;
insert into events_log select * from events_log3;
analyze table events_log compute statistics;
Then it works , result of above query this time is :
TABLE_NAME NUMBER_OF_ROWS SIZE_IN_KB
EVENTS_LOG4 13445 10240
Questions:
1- I read that imp/exp must restore space for HWM high. Why it didn't do that ?
2- Does my trucate / insert solution fine? Do you suggest that I schedule it to run on table periodically?
3- What's your approach to this case?
Thanks
An ounce of prevention is worth a pound of cure