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 

Performance of a query.

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


Joined: 02 Aug 2005
Posts: 75
Topics: 27

PostPosted: Sun Feb 07, 2010 8:37 am    Post subject: Performance of a query. Reply with quote

Hi,
Not sure whether its just a stupid question.. Laughing

In one of my code.. I have written one query to fetch some data and the query is like below..

Code:

SELECT  A.COLNAME1                               
   ,A.COLNAME2
   ,A.COLNAME3
   ,A.COLNAME4
 INTO  :COL-NAME1                                 
      ,:COL-NAME2
      ,:COL-NAME3
      ,:COL-NAME4
FROM  TABLE_NAME A                       
 WHERE  A.COLNAME1       = :WS-COL-NAME
   AND  A.COLNAME2       = :YYYYYYYY       
   AND  A.COLNAME3       = :ZZZZZZZZ       
   AND  A.COLNAME5 = (SELECT MAX (COLNAME5)   
         FROM TABLE_NAME                         
        WHERE A.COLNAME1 = COLNAME1                 
          AND A.COLNAME2 = COLNAME2           
          AND A.COLNAME3 = COLNAME3         
          AND A.COLNAME4 = COLNAME4           
          AND A.COLNAME6 = COLNAME6  )

and my DBA asked to change it like this...

Code:

SELECT  A.COLNAME1                               
   ,A.COLNAME2
   ,A.COLNAME3
   ,A.COLNAME4
 INTO  :COL-NAME1                                 
      ,:COL-NAME2
      ,:COL-NAME3
      ,:COL-NAME4
FROM  TABLE_NAME A                       
 WHERE  A.COLNAME1       = :WS-COL-NAME
   AND  A.COLNAME2       = :YYYYYYYY       
   AND  A.COLNAME3       = :ZZZZZZZZ       
   AND  A.COLNAME5 = (SELECT MAX (COLNAME5)   
         FROM TABLE_NAME B
        WHERE A.COLNAME1 = B.COLNAME1                 
          AND A.COLNAME2 = B.COLNAME2           
          AND A.COLNAME3 = B.COLNAME3         
          AND A.COLNAME4 = B.COLNAME4           
          AND A.COLNAME6 = B.COLNAME6  )


( Notice the difference in the sub-query )
I know both will fetch the same data.. but just want to know is there any performance difference will be noticed with these 2 queries ?


Thanks,
_________________
Regards,
batu
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Terry_Heinze
Supermod


Joined: 31 May 2004
Posts: 391
Topics: 4
Location: Richfield, MN, USA

PostPosted: Mon Feb 08, 2010 12:05 am    Post subject: Reply with quote

I don't think there's a performance difference. Maybe his suggestion was for the purpose of making the query more explicit as far as readability or understandability is concerned? Did you ask what the reasoning of the DBA was?
_________________
....Terry
Back to top
View user's profile Send private message Send e-mail
batu544
Beginner


Joined: 02 Aug 2005
Posts: 75
Topics: 27

PostPosted: Mon Feb 08, 2010 12:30 am    Post subject: Reply with quote

I asked and the answer was the same.. to increase the readability of the query..
_________________
Regards,
batu
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
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