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 

Which is more efficient 'if' or 'where' ?

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


Joined: 10 Dec 2005
Posts: 159
Topics: 75

PostPosted: Sun Oct 22, 2006 10:11 pm    Post subject: Which is more efficient 'if' or 'where' ? Reply with quote

1)
Code:
SELECT PP_PRODTYPE,                         
       ACCT_STAT                             
 INTO :DCLGRB-ACCT-DATA.PP-PRODTYPE,         
      :DCLGRB-ACCT-DATA.ACCT-STAT           
  FROM GRB_ACCT_DATA                         
  WHERE PP_ACCTNUMB  = :PP-ACCTNUMB         
  AND   ACCT_SYSID   = 'IM'       

2)
Code:
 SELECT PP_PRODTYPE,                         
         ACCT_STAT                           
   INTO :DCLGRB-ACCT-DATA.PP-PRODTYPE,       
        :DCLGRB-ACCT-DATA.ACCT-STAT           
    FROM GRB_ACCT_DATA                       
    WHERE PP_ACCTNUMB  = :PP-ACCTNUMB                                       
                                                                   
IF WS-SQL-OK                                 
   IF ACCT-SYSID OF DCLGRB-ACCT-DATA = 'IM'   


Which is more efficient ? If PP_ACCTNUMB is a unique key? Or it's not a unique key, the result would be different?
Back to top
View user's profile Send private message Send e-mail MSN Messenger
CZerfas
Intermediate


Joined: 31 Jan 2003
Posts: 211
Topics: 8

PostPosted: Mon Oct 23, 2006 1:41 am    Post subject: Reply with quote

Every transfer of data from the DB2 address space to your program consumes CPU cycles. Every filtering done on the DB2 side is therefore much more efficient than any program logic.

regards
Christian
Back to top
View user's profile Send private message
issac1029
Intermediate


Joined: 10 Dec 2005
Posts: 159
Topics: 75

PostPosted: Mon Oct 23, 2006 11:29 pm    Post subject: Reply with quote

CZerfas,

Thank you, is there any document that I can refer to study further ?
A senior engineer revise code to case 2), I ask him if this can enhance the efficiency, he did not reply.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
CZerfas
Intermediate


Joined: 31 Jan 2003
Posts: 211
Topics: 8

PostPosted: Wed Oct 25, 2006 2:35 am    Post subject: Reply with quote

To my knowledge the DB2 administration guide has a huge chapter concerning application tuning. Among the discussion of index access and PLAN_TABLE interpretation, you should find more statements of IBM to your theme.

An additional look into a Performance Redbook (SG24-6465-00), available on the IBM web site, is of course always advisable.

regards
Christian
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