Ask the Expert

How to use Oracle table extents to allocate less disk space

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?

    Requires Free Membership to View

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.

This was first published in February 2009

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: