IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

INDEX SEARCH IS FAST?


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Search two or more word with FILEAID Compuware & Other Tools 15
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts first column truncated in search result IBM Tools 13
No new posts Cobol file using index COBOL Programming 2
No new posts ISRSUPC search utility - using high l... TSO/ISPF 2
Search our Forums:

Back to Top