Table Fragmentation & How To Avoid Same: Samadhan
Table Fragmentation & How To Avoid Same: Samadhan
same
January 20, 2011 by samadhan
When a lot of DML operations are applied on a table, the table will become fragmented
because DML does not release free space from the table below the HWM.
HWM is an indicator of USED BLOCKS in the database. Blocks below the high water
mark (used blocks) have at least once contained data. This data might have been deleted.
Since Oracle knows that blocks beyond the high water mark don’t have data, it only reads
blocks up to the high water mark when doing a full table scan.
SQL> commit;
Commit complete.
SQL> commit;
Commit complete.
The difference between two values is 60% and Pctfree 10% (default) – so, the table has
50% extra space which is wasted because there is no data.
Table altered.
STATUS INDEX_NAME
——– ——————————
UNUSABLE BIGIDX
Index altered.
STATUS INDEX_NAME
——– ——————————
VALID BIGIDX
Table created.
Table dropped.
Table renamed.
no rows selected
TABLE_NAME size
—————————— ——————————————
BIG1 42535.54kb
STATUS
——–
VALID
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.5.0 – Pr
oduction
With the Partitioning, OLAP and Data Mining options
Table truncated.
TABLE_NAME size
—————————— ——————————————
BIG1 85536kb
SQL> select table_name, round((num_rows*avg_row_len/1024),2)||’kb’ “size”
2 from user_tables
3 where table_name = ‘BIG1′;
TABLE_NAME size
—————————— ——————————————
BIG1 42535.54kb
TABLE_NAME size
—————————— ——————————————
BIG1 51840kb
TABLE_NAME size
—————————— ——————————————
BIG1 42542.27kb
STATUS
——–
VALID
Expert are always welcome for their valuable comment or suggestion for the above
post.
Share this:
Email
Facebook
Like
Be the first to like this post.
3 Responses
Hi,
If one is working on oracle 10g and above. Then i don’t think there will be much
table space fragmentation. There is a new feature in 10g called automatic segment
space management which prevents fragmentation. However One may need to
reorganize the table because of some High number of chained (actually migrated)
rows.
Apart from the techniques that Samadhan already told. There is one more good
feature in oracle 10g called shrink space command. One can refer it on oracle
documentation.
Hi Vineet,
As disscused please check the post for 10gR1 New Feature SEGMENT
SHRINKING.
http://samadhandba.wordpress.com/2011/02/17/how-to-adjust-the-high-
watermark-in-oracle-10g-%e2%80%93-alter-table-shrink/
Thx….