Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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: 1738
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: 1738
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 SQL - select data available in index Nileshkul DB2 3 Mon Jun 26, 2017 1:30 am
No new posts Identify top 30 big tables or indexes... ashek15 DB2 0 Fri Jun 16, 2017 10:01 am
No new posts Data replication from multiple Db2 ta... kishpra DB2 9 Mon Mar 27, 2017 9:58 pm
No new posts SPUFI -- Joining 3 tables – data in... Sysaron DB2 2 Wed Mar 08, 2017 4:18 am
No new posts To know activities on db2 tables ashek15 DB2 4 Fri Mar 03, 2017 11:23 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us