View previous topic :: View next topic |
Author |
Message |
issac1029 Intermediate

Joined: 10 Dec 2005 Posts: 159 Topics: 75
|
Posted: Sun Oct 22, 2006 10:11 pm Post subject: Which is more efficient 'if' or 'where' ? |
|
|
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 |
|
 |
CZerfas Intermediate
Joined: 31 Jan 2003 Posts: 211 Topics: 8
|
Posted: Mon Oct 23, 2006 1:41 am Post subject: |
|
|
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 |
|
 |
issac1029 Intermediate

Joined: 10 Dec 2005 Posts: 159 Topics: 75
|
Posted: Mon Oct 23, 2006 11:29 pm Post subject: |
|
|
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 |
|
 |
CZerfas Intermediate
Joined: 31 Jan 2003 Posts: 211 Topics: 8
|
Posted: Wed Oct 25, 2006 2:35 am Post subject: |
|
|
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 |
|
 |
|
|