Results 1 to 11 of 11

Thread: table count

  1. #1
    Join Date
    Sep 2003
    Posts
    63

    Unanswered: 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

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    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

  3. #3
    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

  4. #4
    Join Date
    Mar 2004
    Posts
    448
    are you in a partitioned enviroment.

    regards,

    mujeeb

  5. #5
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    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

  6. #6
    Join Date
    Sep 2003
    Posts
    63
    Yes, I am in partitioned environment.
    And I am Querying the CARD column of syscat.tables.

    Thanks
    toby

  7. #7
    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

  8. #8
    Join Date
    Sep 2003
    Posts
    63
    How do I run runstats on all the partitions?

  9. #9
    Join Date
    Mar 2004
    Posts
    448
    I usually use db2_all or rah command.

    regards,

    mujeeb

  10. #10
    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

  11. #11
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •