Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2016
    Posts
    17

    Unanswered: Query about count in db2

    hi, i am using db2 v10.5 i have so many tables when i used count query the output will show no of rows

    but in datastudio 3.2.0 the table cardinality will be different. Can any one explain why it is happening?

  2. #2
    Join Date
    Jul 2016
    Location
    Moscow
    Posts
    294
    Provided Answers: 45
    Hi,

    DS gets the table cardinality from the system catalog.
    It's updated after runstats on this table only (you can update it manually as well if you want).
    Code:
    create table test_card (i int) in userspace1;
    
    select card from syscat.tables where tabschema=current schema and tabname='TEST_CARD';
    CARD: -1
    
    insert into test_card values 1;
    
    select count(1) cnt from test_card;
    CNT: 1
    
    select card from syscat.tables where tabschema=current schema and tabname='TEST_CARD';
    CARD: -1
    
    call admin_cmd((select 'runstats on table '||rtrim(current schema)||'.test_card' from sysibm.sysdummy1));
    
    select card from syscat.tables where tabschema=current schema and tabname='TEST_CARD';
    CARD: 1
    Regards,
    Mark.

  3. #3
    Join Date
    Dec 2016
    Posts
    17
    QUOTE=mark.bb;6646282]Hi,

    DS gets the table cardinality from the system catalog.
    It's updated after runstats on this table only (you can update it manually as well if you want).
    Code:
    create table test_card (i int) in userspace1;
    
    select card from syscat.tables where tabschema=current schema and tabname='TEST_CARD';
    CARD: -1
    
    insert into test_card values 1;
    
    select count(1) cnt from test_card;
    CNT: 1
    
    select card from syscat.tables where tabschema=current schema and tabname='TEST_CARD';
    CARD: -1
    
    call admin_cmd((select 'runstats on table '||rtrim(current schema)||'.test_card' from sysibm.sysdummy1));
    
    select card from syscat.tables where tabschema=current schema and tabname='TEST_CARD';
    CARD: 1
    [/QUOTE]

    Thanks

Posting Permissions

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