IBM MAINFRAME HELP & SUPPORT FORUMS
Technical Forums for IBM Mainframe Applications like COBOL, JCL, CICS, DB2, FileAid, DFSORT, Endevor, Xpediter, CoolGen, CA-7&11, AbendAid, IMS, IDMS, PL/I, MqSeries, SyncSort, Assembler, ChangeMan, Easytrieve, InterTest, REXX, CLIST etc...
 

Tweaking SQL performance

THIS IS AN ARCHIVE FORUM: CLICK HERE TO GO TO THE ORIGINAL TOPIC

 
       IBMMAINFRAMES.com - IBM Mainframe Support Forums Index -> DB2
View previous topic :: View next topic  
Author Message
rohin



Joined: 29 Apr 2005
Posts: 16
Location: Gurgaon, India

Posted: Fri Oct 03, 2008 3:36 am    Post subject: Tweaking SQL performance  

Hi,

Please suggest which of the following is a better option for Cobol DB2 batch program.

1. Open cursor-A, fetch data from cursor-A. Now, use data from cursor-A to execute another SQL like:
EXEC SQL
SELECT SUM(COL_A * COL_B)
FROM TABLE-B
WHERE COL_C = ....
END-EXEC

2. Open cursor-A, fetch data from cursor-A. Now, use data from cursor-A to open another cursor-B like:
EXEC SQL
DECLARE CURSOR_B AS
SELECT COL_A, COL_B
FROM TABLE-B
WHERE COL_C = ....
END-EXEC
and then do sum of multiplication in Cobol.

Data volume could be around 50,000 to 80,000

Please suggest.

Thanks,
Rohin
Back to top  
ashimer



Joined: 13 Feb 2004
Posts: 354
Location: Bangalore

Posted: Fri Oct 03, 2008 2:57 pm    Post subject:  

Why dont you join TABLE-B with the first cursor and do the multiplication in the cursor itself .... Multiplication in DB2 query is not going to eat up CPU time ...
Back to top  
 
       IBMMAINFRAMES.com - IBM Mainframe Support Forums Index -> DB2
Page 1 of 1
THIS IS AN ARCIVE FORUM IN READ ONLY MODE. IF YOU WANT TO ASK YOUR DOUBTS USE THE ACTUAL FORUM