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 > table count

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-10-04, 10:54
toby25 toby25 is offline
Registered User
 
Join Date: Sep 2003
Posts: 63
table count

Hi,

Where can I get a count of the number of rows in a table without having to do a select count(*)? We looked at rowcount column in syscat.systable but it is not reflective of the actual number of rows in a table. is there another column / table to look at?

Thanks,
Toby
Reply With Quote
  #2 (permalink)  
Old 06-10-04, 10:55
Marcus_A Marcus_A is online now
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
If you execute runstats on the table, the information in syscat.systable will be accurate.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #3 (permalink)  
Old 06-10-04, 13:21
toby25 toby25 is offline
Registered User
 
Join Date: Sep 2003
Posts: 63
I ran 'runstats on table with distribution and indexes all'
but it still gives wrong count.
is there anything wrong?

thanks
toby
Reply With Quote
  #4 (permalink)  
Old 06-10-04, 16:17
bmujeeb bmujeeb is offline
Registered User
 
Join Date: Mar 2004
Posts: 448
are you in a partitioned enviroment.

regards,

mujeeb
Reply With Quote
  #5 (permalink)  
Old 06-10-04, 17:45
Marcus_A Marcus_A is online now
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
The column name in syscat.tables with the rowcount is called CARD.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #6 (permalink)  
Old 06-11-04, 11:10
toby25 toby25 is offline
Registered User
 
Join Date: Sep 2003
Posts: 63
Yes, I am in partitioned environment.
And I am Querying the CARD column of syscat.tables.

Thanks
toby
Reply With Quote
  #7 (permalink)  
Old 06-11-04, 11:44
bmujeeb bmujeeb is offline
Registered User
 
Join Date: Mar 2004
Posts: 448
RUNSTATS command collects statistics for a table on the database partition from
which it is invoked. If the table does not exist on that database partition, the
first database partition in the database partition group is selected.

Regards,

mujeeb
Reply With Quote
  #8 (permalink)  
Old 06-11-04, 12:17
toby25 toby25 is offline
Registered User
 
Join Date: Sep 2003
Posts: 63
How do I run runstats on all the partitions?
Reply With Quote
  #9 (permalink)  
Old 06-11-04, 12:28
bmujeeb bmujeeb is offline
Registered User
 
Join Date: Mar 2004
Posts: 448
I usually use db2_all or rah command.

regards,

mujeeb
Reply With Quote
  #10 (permalink)  
Old 06-11-04, 13:02
toby25 toby25 is offline
Registered User
 
Join Date: Sep 2003
Posts: 63
I am use db2_all.
Ran the runstats using db2_all
db2_all "db2 connect to testdb;db2 runstats on table test_table with distribution and indexes all"

but the counts are still not matching.
select count(*) of table and sysstat.tables' CARD column entry does not match.

Thanks,
toby
Reply With Quote
  #11 (permalink)  
Old 06-11-04, 13:23
Marcus_A Marcus_A is online now
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
How far off is it? Is it a mulitple of the number of partitions?
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
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