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 

Query Performance of Join and Nested Query

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


Joined: 26 Aug 2005
Posts: 144
Topics: 73

PostPosted: Thu Jul 24, 2008 4:33 pm    Post subject: Query Performance of Join and Nested Query Reply with quote

Hi all,
Could anyone please tell me if a Join query will take more time to get the data or a nested query.

Thanks in advance.
_________________
Satya
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Jul 24, 2008 7:03 pm    Post subject: Reply with quote

satyenderd,

Joins should always be faster - theoretically and realistically. Subqueries particularly correlated can be very difficult to optimise. If you think about it you will see why - technically, the subquery could be executed once for each row of the outer query

Subqueries such as that described are one instance of the way that SQL implements relational calculus (you will see that it is basically an "Exists" type of
operation). Joins are an implementation of relational algebra. The optimisation
of relational algebraic operations is *very* well understood, while the calculus
is much more difficult to optimise.

Realistically, most good DBMSs will optimise a query such as yours to use a join instead, thus converting the implementation from calculus to algebra. In general, subqueries - particularly correlated - should be avoided unless absolutely necessary. It makes the query harder to read/maintain, pushes more work onto the server, and is generally just a far less appropriate style of SQL.

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
satyenderd
Beginner


Joined: 26 Aug 2005
Posts: 144
Topics: 73

PostPosted: Mon Jul 28, 2008 4:48 pm    Post subject: Reply with quote

Thanks Kolusu.
_________________
Satya
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