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 > select count(*) - Full table scan

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-08-06, 15:42
db2udbgirl db2udbgirl is offline
Registered User
 
Join Date: Mar 2006
Location: Tuticorin, India
Posts: 100
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)
Reply With Quote
  #2 (permalink)  
Old 03-08-06, 16:06
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
select count(*) from table should do a table scan no matter what the conditions.

Andy
Reply With Quote
  #3 (permalink)  
Old 03-08-06, 18:21
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
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
Reply With Quote
  #4 (permalink)  
Old 03-09-06, 11:44
db2udbgirl db2udbgirl is offline
Registered User
 
Join Date: Mar 2006
Location: Tuticorin, India
Posts: 100
Yes, Thats my plan. Thanks guys for your comments.
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