IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

DB2 indexing


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Thu Jun 21, 2012 2:08 pm
Reply with quote

Suppose I have a below query,

Code:
Select emp_id,Dep_id,Name
from tableA
where
Dep_id=20
with ur;

Now on tableA, the indexing sequence is in below format,

Code:
Index info:
TableA.INDX001
emp_id
Dep_id
So in this case would the above index will be considered or it will just ignore and do a table space scan as because of Dep_id is at second position in the index creation??

Thanks,

Rohit
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Jun 21, 2012 2:31 pm
Reply with quote

why don't you look at the EXPLAIN output and tell us the answer to your question?
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Thu Jun 21, 2012 2:46 pm
Reply with quote

It depends on DB2 version, cardinality of emp_id,dep_id, number of pages,clusterratio of the index,... but most likely DB2 will choose a tablescan.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Thu Jun 21, 2012 7:41 pm
Reply with quote

I am trying doing that, but not finding such existing queries. but if any one is already knowing this then would save my time. icon_smile.gif
Aslo current version is V9.1
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Jun 21, 2012 8:07 pm
Reply with quote

Hello,

Quote:
I am trying doing that, but not finding such existing queries.

You should run the Explain on YOUR query - not some existing query.

Quote:
but if any one is already knowing this then would save my time.
The advice you've been given is probably the best you will get with the limited info we have available.

And keep in mind that we are not here to save your time, but to help people with how/why questions and help solve problems. What you are working on Should take your time . . .
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Thu Jun 21, 2012 8:25 pm
Reply with quote

Yes Dick, noted.
I will update you all with the explain result.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts array indexing PL/I & Assembler 4
No new posts Indexing in db2 with expressions DB2 4
No new posts Indexing issue DB2 1
No new posts FIELD(1:4): compilation is indexing t... COBOL Programming 7
No new posts Status AK while using Secondary index... IMS DB/DC 4
Search our Forums:

Back to Top