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 

order of the where clause in SQL

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


Joined: 15 Apr 2005
Posts: 26
Topics: 9

PostPosted: Tue Apr 26, 2005 6:57 pm    Post subject: order of the where clause in SQL Reply with quote

hi

does the order of parameter checks in the Where Clause of an SQL matter the performance.

If Index is defined in the order COL1, COL2, COL3

then would it be more efficient if my where clause has first COL1 check then COL2 check and then COL3 check..??

Thanks
Back to top
View user's profile Send private message
CZerfas
Intermediate


Joined: 31 Jan 2003
Posts: 211
Topics: 8

PostPosted: Wed Apr 27, 2005 5:42 am    Post subject: Reply with quote

Yes, the ordering of predicates in the WHERE clause is relevant for performance. Although, the predicates used to access an index are interpreted first by DB2.

Relevant is this ordering for non-indexed predicates. There the suggestion is to use the one first which filters most. An example: if you don't have indexes for "gender" or "postal code", and you look for male customers living in a particular town, then code the predicate searching for a certain "postal code" before you search for "gender".

This of course is only relevant if you scan millions of records.

regards
Christian
Back to top
View user's profile Send private message
bullfighter
Beginner


Joined: 15 Apr 2005
Posts: 26
Topics: 9

PostPosted: Fri Apr 29, 2005 3:25 pm    Post subject: Reply with quote

thanks christian
_________________
champion is not one who never fails, but one who never quits
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