If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Size table and database in db2 9.5

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-02-11, 10:14
georgipa georgipa is offline
Registered User
 
Join Date: Dec 2002
Location: Madrid - Spain
Posts: 282
Size table and database in db2 9.5

Hi Colleagues,

Somebody can say me how to know the size the table and database in db2 9.5. if you can send me a example is welcome.

Thank you for advenced.
Reply With Quote
  #2 (permalink)  
Old 03-02-11, 10:48
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Providing that your runstats are current:

Code:
with t1 (object_type_code,object_type,schema,object,tabschema,tabname,stats_time,card,pagesize,fpages) as 
(select 1,'Table',t.tabschema,t.tabname,t.tabschema,t.tabname,t.stats_time,t.card,ts.pagesize,double(t.fpages) from syscat.tables as t inner join syscat.tablespaces as ts on (t.tbspace = ts.tbspace) where t.type in ('T','S','H','U') 
) ,
t2 (object_type_code,object_type,schema,object,tabschema,tabname,stats_time,card,pagesize,fpages) as 
( select 2,'Index',i.indschema,i.indname,i.tabschema,i.tabname,i.stats_time,cast(null as bigint),ts.pagesize,double(i****eaf) from syscat.indexes as i inner join syscat.tablespaces as ts on (i.tbspaceid = ts.tbspaceid) 
) ,
t3 (object_type_code,object_type,schema,object,tabschema,tabname,stats_time,card,pagesize,fpages) as 
( select * from t1 
  union all 
  select * from t2 
),
t4 (object_type_code,object_type,schema,object,tabschema,tabname,stats_time,card,pagesize,fpages,bytes) as 
( select t3.*,case when fpages < 0 then 0 else fpages*pagesize end as bytes from t3 
) ,
t4a (object_type_code,object_type,schema,object,tabschema,tabname,stats_time,card,pagesize,fpages,bytes) as 
( select * from t4 
  union all 
  select 3,'Total',tabschema,tabname,tabschema,tabname,cast(null as timestamp),cast(null as bigint),cast(null as int),cast(null as double),sum(bytes) from t4 
  group by (3,'Total',tabschema,tabname,tabschema,tabname,cast(null as timestamp),cast(null as bigint),cast(null as int),cast(null as double)) 
  union all 
  select 4,'Schema Total',cast(null as varchar(128)),cast(null as varchar(128)),tabschema,cast(null as varchar(128)),cast(null as timestamp),cast(null as bigint),cast(null as int),cast(null as double),sum(bytes) from t4 
  group by (4,'Schema Total',cast(null as varchar(128)),cast(null as varchar(128)),tabschema,cast(null as varchar(128)),cast(null as timestamp),cast(null as bigint),cast(null as int),cast(null as double)) 
  union all 
  select 5,'Database Total',cast(null as varchar(128)),cast(null as varchar(128)),cast(null as varchar(128)),cast(null as varchar(128)),cast(null as timestamp),cast(null as bigint),cast(null as int),cast(null as double),sum(bytes) from t4 
  group by (5,'Database Total',cast(null as varchar(128)),cast(null as varchar(128)),cast(null as varchar(128)),cast(null as varchar(128)),cast(null as timestamp),cast(null as bigint),cast(null as int),cast(null as double)) 
  
)select t4a.*,bytes/1024 as KB,(bytes/1024)/1024 as MB,((bytes/1024)/1024)/1024 as GB from t4a 
order by tabschema,tabname,object_type_code,object
Andy
Reply With Quote
  #3 (permalink)  
Old 03-02-11, 11:06
georgipa georgipa is offline
Registered User
 
Join Date: Dec 2002
Location: Madrid - Spain
Posts: 282
Thank you AR_Winner,

You can explain me how to execute this you send me. Please.

Greethings.
Reply With Quote
  #4 (permalink)  
Old 03-02-11, 11:15
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
It is a query. Run it like you would any other.

Andy
Reply With Quote
  #5 (permalink)  
Old 03-14-11, 11:25
db2girl db2girl is offline
∞∞∞∞∞∞
 
Join Date: Aug 2008
Location: Toronto, Canada
Posts: 1,816
Andy, I'm trying to execute your query and getting:

SQL0104N An unexpected token "**" was found following "s.pagesize,double(i*".
Expected tokens may include: "<factor>". SQLSTATE=42601


What is "double(i****eaf) from syscat.indexes" ?
Reply With Quote
  #6 (permalink)  
Old 03-14-11, 11:31
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
It must have been some sort of cut and paste error. it should be: "double(i****eaf)"


Andy
Reply With Quote
  #7 (permalink)  
Old 03-14-11, 11:35
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
It is some sort of posting error/bug. When I put the text in the message it looks fine, but when I post it it makes it look like that. I will try again. It should be: double(i. nleaf)

I had to put a blank space before nleaf so it would come out properly. Remove it before you run the script.

Andy
Reply With Quote
  #8 (permalink)  
Old 03-14-11, 11:53
tonkuma tonkuma is online now
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,195
Quote:
... double(i. nleaf)
... Remove it before you run the script.
Blanks before or after a period which separates a qualifier and a object name would be allowed in SQL syntax.
So, removing blanks would be not neccesary.
Reply With Quote
  #9 (permalink)  
Old 03-14-11, 11:58
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Yes, but the blank makes it looks funny (at least to me).

Andy
Reply With Quote
  #10 (permalink)  
Old 03-14-11, 23:26
db2girl db2girl is offline
∞∞∞∞∞∞
 
Join Date: Aug 2008
Location: Toronto, Canada
Posts: 1,816
Thanks, I should have realized it was a posting error.

How do you get the size of LF/LOB/XML columns? Do you use some table function / admin view? I used the inspect utility in the past.
Reply With Quote
  #11 (permalink)  
Old 03-15-11, 05:25
Mathew_paul Mathew_paul is offline
Registered User
 
Join Date: Oct 2007
Posts: 200
hi
off topic question.
is there way to find out how many % temp space is been used by particular application (agentid).

regds
Paul
Reply With Quote
  #12 (permalink)  
Old 03-15-11, 12:47
nvk@vhv nvk@vhv is offline
Registered User
 
Join Date: Jan 2010
Posts: 294
Yep,

check "get snapshot for table.." output. It also lists Temp-Tables and the Agentid of the Owner. Tried to find an example on my databases, but had no luck.
Reply With Quote
  #13 (permalink)  
Old 03-15-11, 19:59
db2girl db2girl is offline
∞∞∞∞∞∞
 
Join Date: Aug 2008
Location: Toronto, Canada
Posts: 1,816
You can also use db2pd with -tcb
Reply With Quote
  #14 (permalink)  
Old 03-16-11, 01:53
Mathew_paul Mathew_paul is offline
Registered User
 
Join Date: Oct 2007
Posts: 200
thks nvk and bella,

bella but db2pd -tcb won't give the agentid details ??

regds
Paul
Reply With Quote
  #15 (permalink)  
Old 03-16-11, 08:21
db2girl db2girl is offline
∞∞∞∞∞∞
 
Join Date: Aug 2008
Location: Toronto, Canada
Posts: 1,816
SchemaNm column should give you the application handle.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On