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 

Multirow performance

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


Joined: 02 Dec 2002
Posts: 629
Topics: 176
Location: Stockholm, Sweden

PostPosted: Wed Jan 08, 2014 6:30 am    Post subject: Multirow performance Reply with quote

I have worked a fair bit with multirow fetch processing and I hit upon the following "problem" and wonder if it's doable.

I fetch 100 rows at a time from a table (let's say I'm fetching employee number, hire date from the table, and emp.no is sorted in ascending order). The idea is that each time, I need the hire date, I can search using a binary search on the 100 rows read in to see if the employee is in the CURRENT block of 100 employees. Normally, I would expect to get a number of hits within this table and therefore avoid a "simple" select from the table based on the emp.no.

Let's assume I've done my binary search and didn't find the employee. Let's also assume that the first fetch gave me employees 56-198 (with gaps in the numbers). Now let's assume that the employee I now want is number 1500. Yes, I can loop fetching 100 rows at a time, binary search to see if I found number 1500 and as soon as I do, I'm done.

Is there a way of "jumping" from a starting employee of 56 directly to 1500 so I avoid all the fetches between 199 and 1499 (which will never contain my required information).

Yes, I know I could close the cursor and then reopen it, but that has (?) to be heavier than fetching 100 rows at a time

I suppose I'm looking for a way of telling DB2 that the next fetch I want should start with emp.no = 1500, skipping all the previous rows.
_________________
Michael
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Wed Jan 08, 2014 11:54 am    Post subject: Reply with quote

misi01,

Unless I am missing something, If you have a index defined on the employee number, isn't a single SELECT with Employee number and Fetch 1st n rows more effective than having a multi row fetch and a binary search?

I suppose you have a Seqnum to number the records using ROWNUMBER in the multi-row fetch and then jump to the next record using that rownumber record in the program.

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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