Home » SQL & PL/SQL » SQL & PL/SQL » how to calculate size of table
how to calculate size of table [message #18704] Mon, 11 February 2002 11:48 Go to next message
Joan
Messages: 36
Registered: February 2002
Member
How do you calculate size of the table in bytes if you have number of rows to be loaded. eg 1000000.

Thanks in advance
Re: how to calculate size of table [message #18707 is a reply to message #18704] Mon, 11 February 2002 18:48 Go to previous messageGo to next message
Satish Shrikhande
Messages: 167
Registered: October 2001
Senior Member
Suppose, you have to create a new table and insert some data into it, or table already exists and you will make inserts. You want to estimate the final size of your table, for example you want to set correct storage parameters.

You can do it in two ways:

Using internal statistics.

Math estimation.
It's very rough estimation.

I-st method - using statistics

Analyze statitics for the table.

From SQLPlus run the following command:

ANALYZE TABLE
COMPUTE STATISTICS;

or

ANALYZE TABLE
ESTIMATE STATISTICS;

Make select form DBA_TABLES, ALL_TABLES or USER_TABLES dictionary view.

SELECT avg_row_len
FROM dba_tables
WHERE table_name = '
';

where

avg_row_len - is an average row length (in bytes), including row overhead;

<ESTIMATED_TABLE_SIZE> = avg_row_len * number_of_rows * (1 + PCTFREE/100) * 1.15

where number_of_rows - expected number of rows in you table;
1.15 - just in case :).

NOTE: If it's a new table or it's empty, you may insert some "demo" records before analyzing the table.

II-nd method - using math estimation

Calculate maximum row length of the table based on the following facts:

CHAR( n ), VARCHAR2( n ) - n bytes

DATA - 7 bytes;

NUMBER( p, s ) = floor( (p+1)/2 ) + 1, if it's a negative number - add one byte (+1).

For example, Oracle uses 3 bytes to store number: 512 (NUMBER(3)).

<ESTIMATED_TABLE_SIZE> =
MAX_ROW_LENGTH * (1 + PCTFREE/100) * number_of_rows * 1.15

where 1.15 - just in case :).
Re: how to calculate size of table [message #18709 is a reply to message #18707] Mon, 11 February 2002 19:50 Go to previous messageGo to next message
kuldeep singh
Messages: 2
Registered: February 2002
Junior Member
I have a table of 1000 record's and now want to calculate it's size.So plz tell me how can i do it.
Re: how to calculate size of table [message #18738 is a reply to message #18707] Tue, 12 February 2002 21:52 Go to previous messageGo to next message
Satish Shrikhande
Messages: 167
Registered: October 2001
Senior Member
What's the structure of your table
Re: how to calculate size of table [message #20155 is a reply to message #18707] Thu, 02 May 2002 00:01 Go to previous message
Michael Rydtoft
Messages: 1
Registered: May 2002
Junior Member
You can issue the command:
SELECT SUM(BYTES) FROM USER_SEGMENTS WHERE SEGMENT_TYPE='xxxx';

xxxx is the name of the table you want the size of.
Previous Topic: Linking table?-URGENT
Next Topic: What Hapens to Index When I Truncate the source Table
Goto Forum:
  


Current Time: Wed Apr 24 23:47:01 CDT 2024