Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Table Size

Status
Not open for further replies.

new2db2

MIS
Oct 17, 2002
5
0
0
US
Is is possbile to calcuate table size from the syscat tables? If so, how would one go about doing so?

Thanks!
 
Hi,
You can check the table size by running a REORGCHK with update statistics. then one of the values displayed for each column is TSIZE that is the table size so just run runstats for the desire table.
## reorgchk update statistics on table schemaname.urtabname

Remember to update your statistics before you select any value from the syscat tables.
If you check the documentation for REORGCHK it will tell you the formula to calculate TSIZE from syscat tables.
It is calculated by multiplying the number of rows found in the table ie, CARD value from syscat.tables for your table, with the average row lenght. To calculate average row length you have to see the syscat.columns table. Avg row lenght is calculated as sum of avg column length, ie, AVGCOLLEN value from syscat.columns for your table, with a row overhead of 10 per column.
So the formula is CARD*(SUM(AVGCOLLEN)+10)
eg if CARD=9 and sum(avgcollen) is 51 TSIZE is 9*(51+10)=549.

the sql statement for that would be
select a.CARD * (sum(b.AVGCOLLEN)+10) from syscat.tables as a, syscat.columns as b where a.TABNAME ='urtabname' and b.TABNAME = 'urtabname' group by a.CARD

Hope you find this useful
Bye
 
Thanks, one more question. Does this provide size in bytes? Thanks again for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top