When there are lot updates, deletes inside database, it creates lot of empty pockets of space that are not large enough to insert new data. We call this type of empty space as fragmented free space.
Database performance can be impacted by such fragmented space. The process of combining fragmented space into one big free space is known as de-fragmentation.
One of the simplest ways to do it by shrinking table, index segments to reclaim the wasted space. But before you can directly shrink table / index, you must run Oracle segment advisor to get recommendations as to how much space can you reclaim.
In the below activity I will show you how to work with Oracle segment advisor:
Full article link is here: https://www.support.dbagenesis.com/post/oracle-segment-advisor
3. Create test table & index
Let us create a test table, insert some records and create an index into the
above tablespace
Note: you can use this method to create new tables into a different
tablespace even though the default tablespace of a user is different.
7. Let us check the size of each segment (table and index)
8. Delete some rows
Let us delete half of the rows from the table. Note, the below
procedure is deleting alternate rows from the table which will create
lot of fragmented space
9.
10.
11. Analyze table & index again
Now that we have delete half of the rows, let us gather stats
for table and index again
Let us check the size of each segment (table and index)
Note: even after deleting half of the records, the segment size
will still show same as it was before delete.
12.
13. Run Oracle segment advisor
Even though we have delete half of the rows, the statistics
show no change. We will run Oracle segment advisor and see
what recommendations we will get
Create advisor task for table