MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

INDEX scan or Table Scan

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
Dip
Beginner


Joined: 24 Mar 2006
Posts: 27
Topics: 14

PostPosted: Wed May 23, 2007 4:49 pm    Post subject: INDEX scan or Table Scan Reply with quote

We are planning to build a index on a date field (late say ABC_DT)in a table. AT the same time our anticipation is that most of the records (80%) will be having NULL populated in that Date field (i think NULL in a index field is possible).

In this scenario how the below queries will perform in a batch job?

Select FIELD1, FIELD2 from table where ABC_DT = 'XXXX-XX-XX-XX.XX.XX.XXXXXX' ;

Select FIELD1, FIELD2 from table where ABC_DT IS NOT NULL;

Will it go for a INDEX scan?

OR

DB2 will internally perform a table scan as most of the records are having NULL populated in the INDEX field?
Back to top
View user's profile Send private message Yahoo Messenger
videlord
Beginner


Joined: 09 Dec 2004
Posts: 147
Topics: 19

PostPosted: Wed May 23, 2007 9:54 pm    Post subject: Reply with quote

based on the statistic information, if requested data are more than 25% of total records, DB2 optimizer will use table scan instead of index scan

in your case, all requested data are less than 20% , index will be used if the statistic information in catalog table is correct
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu May 24, 2007 5:44 am    Post subject: Reply with quote

Quote:

Date field (i think NULL in a index field is possible).


you canNOT have NULLS if the index is a primary index.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Dip
Beginner


Joined: 24 Mar 2006
Posts: 27
Topics: 14

PostPosted: Thu May 24, 2007 3:58 pm    Post subject: Reply with quote

Sorry.. didnt mention it.. It is not a primary index..
Back to top
View user's profile Send private message Yahoo Messenger
pharia01
Beginner


Joined: 07 Sep 2006
Posts: 3
Topics: 0

PostPosted: Fri May 25, 2007 5:15 pm    Post subject: Reply with quote

Videlord,

Quote:

based on the statistic information, if requested data are more than 25% of total records, DB2 optimizer will use table scan instead of index scan


just curious, where did you get info about 25% cutoff mark?

Thanks,
pharia01
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group