Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / January 2008

Tip: Looking for answers? Try searching our database.

Table size in bytes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gregor Kovač - 31 Jan 2008 08:03 GMT
Hi!

How can I see the actual size of a table is bytes?
I could to a count on table and multiply by page size, but we are using
VARCHARs and I'm affraid that is not the correct value.
I could also find the file that a table is stored in, but I don't know where
to find this information. Where is this information stored in a database?

Thanks and best regards,
       Kovi

Signature

____________________________

|http://kovica.blogspot.com|
-----------------------------~-~-~-~-~-~-~-~-~-~-
|  In A World Without Fences Who Needs Gates?   |
|              Experience Linux.                |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
spider007 - 31 Jan 2008 09:01 GMT
> Hi!
>
[quoted text clipped - 14 lines]
> |              Experience Linux.                |
> -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-

You could try this out
select substr(a.tabschema,1,40) as TABLE_SCHEMA, substr(a.tabname,
1,40) as TABLE_NAME, card, stats_time, sum(avgcollen) as ROW_LENGTH
from syscat.tables a,syscat.columns b where a.tabschema = b.tabschema
and a.tabname = b.tabname and a.tabschema not like '%SYS%' group by
substr(a.tabschema,1,40),substr(a.tabname,1,40),card,stats_time order
by card desc with ur

On multiplying "card" and "ROW_LENGTH", we would get estimated size of
the tables in  bytes.

HTH
-Saurabh
Knut Stolze - 31 Jan 2008 09:47 GMT
>> Hi!
>>
[quoted text clipped - 26 lines]
> On multiplying "card" and "ROW_LENGTH", we would get estimated size of
> the tables in  bytes.

I'm curious: what you would do with this information?  You can't use it to
estimate disk size because counting pages would be much more reliable for
this.

Signature

Knut Stolze
DB2 z/OS Utilities Development
IBM Germany

stefan.albert - 31 Jan 2008 11:25 GMT
> Hi!
>
[quoted text clipped - 3 lines]
> I could also find the file that a table is stored in, but I don't know where
> to find this information. Where is this information stored in a database?

Of course you can try this with the information taken from the
catalog. But the statistics have to be actual...

db2pd -db DB -tcbstats

gives a more reliable output - you can also specify the tablespace
(and table ?).

The size of the file is also a way - but this works for SMS only:
Derive the containers of the tablespace where your table lives.
Then the files have the tableid in their names in these containers.
There can be different types like *.dat  (data) *.INX *.IN1 (indexes)
and others.
They give you the current usage on disk for data and indexes and lobs.

db2pd also gives the sizes of indexes...
Gregor Kovač - 31 Jan 2008 12:10 GMT
> The size of the file is also a way - but this works for SMS only:
> Derive the containers of the tablespace where your table lives.
> Then the files have the tableid in their names in these containers.
> There can be different types like *.dat  (data) *.INX *.IN1 (indexes)
> and others.
> They give you the current usage on disk for data and indexes and lobs.

Thanks, this is what I was looking for.

Best regards,
       Kovi
Signature

____________________________

|http://kovica.blogspot.com|
-----------------------------~-~-~-~-~-~-~-~-~-~-
|  In A World Without Fences Who Needs Gates?   |
|              Experience Linux.                |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Gregor Kovač - 31 Jan 2008 12:11 GMT
I found out that you could get the actual size of a table TABLE1 with this
SQL:

SELECT TABSCHEMA, TABNAME, DATA_OBJECT_P_SIZE + INDEX_OBJECT_P_SIZE +
LONG_OBJECT_P_SIZE + LOB_OBJECT_P_SIZE + XML_OBJECT_P_SIZE AS TOTAL_SIZE
FROM SYSIBMADM.ADMINTABINFO WHERE TABNAME = 'TABLE1'

Signature

____________________________

|http://kovica.blogspot.com|
-----------------------------~-~-~-~-~-~-~-~-~-~-
|  In A World Without Fences Who Needs Gates?   |
|              Experience Linux.                |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.