Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2006
    Location
    Tuticorin, India
    Posts
    103

    Unanswered: select count(*) - Full table scan

    If I perform a select count(*) from tred.order_delivery query will it internally perform a full table scan to determine the row count for the following scenario
    case 1: There is a primary key on a column
    case 2: There is a compound key on 1 columns col1, col2
    case 3: No primary key in the table (Just for my education)

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    select count(*) from table should do a table scan no matter what the conditions.

    Andy

  3. #3
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    Usually DB2 will count the index rows (the smallest available index) instead of reading the table rows, since there is always one index row for each data row (even if the index is not unique). But if the table was small enough, then it might just use the table rows instead.

    You can try this out and evaluate the visual explain in the Control Center to see the access path.
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

  4. #4
    Join Date
    Mar 2006
    Location
    Tuticorin, India
    Posts
    103
    Yes, Thats my plan. Thanks guys for your comments.

Posting Permissions

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