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
 
INDEX SEARCH IS FAST?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
sararaju

New User


Joined: 04 May 2005
Posts: 25

PostPosted: Thu May 26, 2005 9:41 am    Post subject: INDEX SEARCH IS FAST?
Reply with quote

WHY INDEX READING IS FASTER THAN SEQUENTIAL READ AND HOW?

FOR EXAMPLE WE HAVE 30 RECORDS. IF I WANT TO READ THE 30TH RECORD I SUPPOSE TO BYPASS UPTO 29TH RECORD. THIS IS SEQUENTIAL READ.WHERE IN INDEX WE HAVE READ THE KEY VALUE UPTO 29TH RECORD. THEN WHY PEOPLE ARE SAYING INDEX READING IS FASTER THEN SEQUNTIAL? PLS CLARIFY IT.
Back to top
View user's profile Send private message

SteveConway

New User


Joined: 26 May 2005
Posts: 28
Location: Northern VA, USA

PostPosted: Fri May 27, 2005 8:28 pm    Post subject: Re: INDEX SEARCH IS FAST?
Reply with quote

Hi, Sararaju. I will assume you are speaking of something like a VSAM KSDS.
An index record is small, generally containing pointers to a particular data area within the file, noting the highest and lowest key values of the records within that area.
Let's assume, for example's sake, that we have a file with 1,000 records. Let's also assume that this particular file is structured in a way that each index record's high and low key values encompass about 100 records.
If the record we want to get to is #810 (relative to the beginning of the file) how many records do we have to read to get there?
If we read sequentially, we have to read 809 records first, then our record.
If we read the indexes, we read 9 index records (when the high value pointer is > our desired record, we can stop reading index records), go to the data area that has our record, and read 8 records, then ours. Total 17 records read to get to ours.
The bigger the file, the bigger the resource savings.
Obviously, this is a simplified, non-specific response, just to illustrate index vs. sequential.
In a (book) library, you don't read each book's title starting at bookshelf #1 until you find the one you want. You use the classification system for books to get you to the correct bookshelf (here it's the Dewey Decimal System), then home in on your book.
Examples are endless...


Cheers,,,Steve
Back to top
View user's profile Send private message
SteveConway

New User


Joined: 26 May 2005
Posts: 28
Location: Northern VA, USA

PostPosted: Fri May 27, 2005 8:36 pm    Post subject: Re: INDEX SEARCH IS FAST?
Reply with quote

In my previous example, I should have stated some assumptions.
If all your records are the same size, and your keys are distributed evenly, and there is no (or no variable) free space in the data set, you may be able to go directly to the desired record in a more efficient fashion.
Real world data has a tendency to be more messy, with uneven distribution of keys and variable record lengths, which would require you to read each record, compare its key, get the record's length so you can bump to the next record, and so on. Add in free space of possibly varying amounts in each data CI and CA (in a KSDS), and the use of the index becomes more obviously useful.


Cheers,,,Steve
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm
No new posts Search for a string in many PDS KARTHIGADEVI CLIST & REXX 5 Fri Sep 08, 2017 2:32 pm
No new posts Confusion b/w index and subscript Deepak kumar25 Mainframe Interview Questions 7 Thu Aug 31, 2017 6:50 am
No new posts SQL - select data available in index Nileshkul DB2 3 Mon Jun 26, 2017 1:30 am
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm

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