Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Efficiency - Joining various tables vs individual select

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
TS70363

New User


Joined: 07 Apr 2010
Posts: 94
Location: Bangalore, India

PostPosted: Mon Mar 25, 2013 10:23 pm    Post subject: Efficiency - Joining various tables vs individual select
Reply with quote

Hi,

Requirement - to be accomplished via COBOL

TABLE A : TABLE B = 1 : many

1. Select 1 row from TABLE A - about 600 bytes of data per row.
2. Fetch upto 100 records from TABLE B based on COL1 from TABLE A - about 20 bytes of data per row.
3. Perform 1 and 2 until a list of values - COL1, gets exhausted

Can any one suggest the better option in terms of efficiency, performance and cost from the below 2 - both the tables have millions of rows?

A. Use 1 cursor, use JOIN to combine TABLE A & TABLE B and retrieve the required rows.
B. Use 2 cursors, open cursor 1, fetch first row, open cursor 2, fetch all rows, close cursor 2, fetch second row in cursor 1, open cursor 2, fetch all rows, close cursor 2 and so on.



Thanks
TS70363
Back to top
View user's profile Send private message

Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 2038
Location: NY,USA

PostPosted: Mon Mar 25, 2013 10:38 pm    Post subject:
Reply with quote

Try for multi row fetch for cursor 2
Back to top
View user's profile Send private message
TS70363

New User


Joined: 07 Apr 2010
Posts: 94
Location: Bangalore, India

PostPosted: Tue Mar 26, 2013 8:50 am    Post subject:
Reply with quote

Hi Rohit,

Yes, cursor 2 is a multi-row fetch cursor..

But question over here is, which one of the 2 options is better
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1013
Location: India

PostPosted: Tue Mar 26, 2013 12:20 pm    Post subject:
Reply with quote

Hi TS70363,

Use Joins and give good filtering conditions in the WHERE clause(not flag indicators having low cardinality).

Thanks,
Sushanth
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 2038
Location: NY,USA

PostPosted: Tue Mar 26, 2013 5:45 pm    Post subject:
Reply with quote

Hi,
join should be the good option over here and have a multi row fetch , share your explain results. 1st option should give less MIPS than 2.so try it and share your results.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Varying List Select SQL Query In DB2 ... NikhilGuptaGaya DB2 5 Wed Jun 27, 2018 11:01 pm
No new posts SYSIBM Catlog tables to see DDL chang... rakesh17684 DB2 2 Fri Jun 08, 2018 3:43 am
No new posts How to force a select query to abend neo4u DB2 7 Mon Apr 23, 2018 1:36 pm
No new posts SELECT TO MULIPLE OUTFIL speermb DFSORT/ICETOOL 5 Fri Mar 23, 2018 10:44 pm
No new posts How to select record x+7 or x+2 based... JoAnn Kulcyk SYNCSORT 6 Tue Jan 16, 2018 10:49 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us