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 predicates in an SQL query

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


Joined: 04 Dec 2002
Posts: 8
Topics: 6

PostPosted: Mon Nov 21, 2005 3:33 pm    Post subject: Order of predicates in an SQL query Reply with quote

Does order of predicates in an SQL query with a JOIN matter as far as the performance of the query is concerned ?

For example,

SQL1
Select A.col1, A.col2, B.col3

from TBL1 A
,TBL1 B

where A.col6 = B.col6 >>>> This is the join condition
and A.col4 = '7777779' and
A.col5 = 0 and
B.col4 = 'ABC';

SQL2
Select A.col1, A.col2, B.col3
from TBL1 A
,TBL1 B

where A.col4 = '7777779' and
A.col5 = 0 and
B.col4 = 'ABC' and
A.col6 = B.col6 >>>> This is the join condition


Which of the SQLs will be faster with DB2 V7 (and later versions) or both will have the same performance ?
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: Mon Nov 21, 2005 7:11 pm    Post subject: Reply with quote

abhayasahoo,

We cannot just tell you just by looking at the sql's. we need to know how the indexes are defined on the columns. Run an explain on the both the sqls' and then you will have fair idea about the predicate evaluation.

I would suggest that you read this which explains in detail about General rules about predicate evaluation

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNAPH11/6.3.3?DT=20010710165542

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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