Manage Learn to apply best practices and optimize your operations.

How to use Oracle table extents to allocate less disk space

Oracle expert Brian Peasland explains how to use table extents to allocate less disk space in Oracle.

I have a table in Oracle 10g which has about 5.7 billion records and is split into 500 partitions. The disk space occupied by the table is much larger than what I think it should be.

I query dba_partitions for one specific partition and get avg_row_len = 27 and num_rows = 411482598. This should equate to about 10.34 GB (Select 411482598 * 27 / Power (1024,3) From Dual). The blocks column in this table is 1653190 which equates to a size of about 12.61 GB (Select 1653190 * 8192 / Power (1024,3) From Dual). So far, I am happy.

Now I query dba_segments with the table name and partition name and get bytes = 26549944320. This equates to a size of 24.73GB, which is almost double what I found from dba_partitions. Why is this happening and is there a way to fix this?

Keep in mind that a segment is composed of one or more extents. And those extents are a specific size. Let's assume the extent size is 1MB and my table has two rows of data, each averaging 1KB in size. The size from your calculations would be 2KB in total size, yet querying DBA_SEGMENTS would show the table is 1MB in size. This is because I cannot have less than one extent in the segment. If you want to allocate less space, recreate the table with a smaller extent size.

Dig Deeper on Oracle database backup and recovery

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.