Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

RANDOM vs. DYNAMIC on indexed output file
Is there any difference between opening as OUTPUT an indexed file with
ACCESS MODE RANDOM and ACCESS MODE DYNAMIC?

I know the difference when opening for INPUT or I-O, but I can't think of
how one of the above would be preferred over the other.

What brings this fairly silly question up is that I have a sorted input file
that I read in, extract some data from, and write the "modified" version of
some of the records to an indexed output file.  I had been opening the
output file as SEQUENTIAL, and this worked fine.  That is, until I needed to
add a "header" record.   I can't actually create the header record until
I've read all of the other records, so I put my logic to create the header
after I finished processing the input file.  This, of course, caused a write
error with status '21' (sequence error).

I'm not really looking for a solution, because I already have two:
1) Add a trailer record instead of a header record.
or
2) Define output file as ACCESS RANDOM instead of SEQUENTIAL.

But it made me wonder what difference it might make using ACCESS DYNAMIC
instead of RANDOM.
I tried both ways and DYNAMIC *seems* to run faster, but I don't know if
that's just because of CPU utilization issues or if it actually makes sense
that DYNAMIC would be faster because it would do SEQUENTIAL for 99% of the
records.

Frank


---
Frank Swarbrick
Senior Developer/Analyst - Mainframe Applications
FirstBank Data Corporation - Lakewood, CO  USA

Report this thread to moderator Post Follow-up to this message
Old Post
Frank Swarbrick
06-03-05 08:55 AM


Re: RANDOM vs. DYNAMIC on indexed output file
hi!

the best way is:
open output the indexed file
write sequentially all the file
close
open i-o
set the key and write the label record
close

doing so, the computer write all the index really in order and it's very
fast.
and all the next read access will fly.
you can do it only if you declare the file for dynamic.

bye!
gz

"HeyBub" <heybubNOSPAM@gmail.com> wrote in message
news:119vfscobpe0cbf@news.supernews.com...
> Frank Swarbrick wrote: 
>
> Well, you actually CAN write the header record first. Write a dummy
> record - with the low key - then, when finished update it with record
> counts or whatever.
>
> 
>
> If you can't really tell the difference in your timing tests, then it
> probably doesn't make any difference.
>



Report this thread to moderator Post Follow-up to this message
Old Post
g z2
06-03-05 08:55 PM


Re: RANDOM vs. DYNAMIC on indexed output file
> the computer write all the index really in order and it's very
> fast. and all the next read access will fly.
> you can do it only if you declare the file for dynamic.

Writing an indexed file in ascending key order is not necessarily the
best mechanism to get an efficient index.  Many b-tree indexes need to
be rotated to keep the tree balanced and an all ascending key will mean
that there will be the most number of rotations required.

I have seen some systems (eg early RM Cobol) where the index was never
rotated and loading a file in ascending key sequence resulted in the
worst possible index that was basically a single linked list.  In these
cases it was necessary to sort the records to a random sequence in
order that the index resulted in a reasonable balance.


Report this thread to moderator Post Follow-up to this message
Old Post
Richard
06-04-05 08:55 AM


Re: RANDOM vs. DYNAMIC on indexed output file
This is a good reason for referring to the language reference manual
and programmers guide for the particular version of COBOL in use for
their recommendations.


Report this thread to moderator Post Follow-up to this message
Old Post
Robert Jones
06-04-05 01:55 PM


Re: RANDOM vs. DYNAMIC on indexed output file
Hi Frank,

In an IBM Mainframe environment the following applies.  I assume it's
the same for others.

With RANDOM only random access of recs is allowed; with SEQUENTIAL only
seq access of recs is allowed.

With DYNAMIC both modes of access is allowed.

Use READ NEXT when doing a seq read; use READ when doing a random read.

Just make sure the key field in the FD contains the value you need.


Report this thread to moderator Post Follow-up to this message
Old Post
slade2
06-05-05 01:55 AM


Re: RANDOM vs. DYNAMIC on indexed output file
> Use READ NEXT when doing a seq read; use READ when doing a random read.

The question was about OPEN OUTPUT, so the difference in the READ
statement does not apply.


Report this thread to moderator Post Follow-up to this message
Old Post
Richard
06-05-05 01:55 AM


Re: RANDOM vs. DYNAMIC on indexed output file
"Robert Jones" <rjones0@hotmail.com> wrote in message
news:1117878926.227936.129310@z14g2000cwz.googlegroups.com...
> This is a good reason for referring to the language reference manual
> and programmers guide for the particular version of COBOL in use for
> their recommendations.
>

I agree.
in my experience (ufas file system  on bull ) loading sequentially an
indexed file was the best mode to obtain a very fast access file.
but surely different implementation of cobol and file system can achieve
different results.
regards!



Report this thread to moderator Post Follow-up to this message
Old Post
g z2
06-06-05 01:55 PM


Re: RANDOM vs. DYNAMIC on indexed output file
My indexed file system is IBM VSAM/VSE, so I would guess (or hope!) that if
I declare the access as being sequential it would handle this in the most
efficient manner possible.  Now if I declared it as RANDOM or DYNAMIC I'm
not so sure, though DYNAMIC did appear to run faster than RANDOM.

In any case, I'm going to depend on the file system to work efficiently
until such time as I determine that it's not.

Thanks for the info, in any case.
Frank
 
> the computer write all the index really in order and it's very
> fast. and all the next read access will fly.
> you can do it only if you declare the file for dynamic.

Writing an indexed file in ascending key order is not necessarily the
best mechanism to get an efficient index.  Many b-tree indexes need to
be rotated to keep the tree balanced and an all ascending key will mean
that there will be the most number of rotations required.

I have seen some systems (eg early RM Cobol) where the index was never
rotated and loading a file in ascending key sequence resulted in the
worst possible index that was basically a single linked list.  In these
cases it was necessary to sort the records to a random sequence in
order that the index resulted in a reasonable balance.




Report this thread to moderator Post Follow-up to this message
Old Post
Frank Swarbrick
06-07-05 01:55 AM


Re: RANDOM vs. DYNAMIC on indexed output file
Hi "Slade",

This makes sense when you're talking about reads, but when you're talking
about writes where mode is DYNAMIC what is the difference between a "random"
write and a "sequential" write.  I don't see anything that documents
something similar to "READ NEXT", such as "WRITE NEXT".

I'm in an IBM mainframe environment also (VSE/ESA).

Thanks,
Frank
 
Hi Frank,

In an IBM Mainframe environment the following applies.  I assume it's
the same for others.

With RANDOM only random access of recs is allowed; with SEQUENTIAL only
seq access of recs is allowed.

With DYNAMIC both modes of access is allowed.

Use READ NEXT when doing a seq read; use READ when doing a random read.

Just make sure the key field in the FD contains the value you need.




Report this thread to moderator Post Follow-up to this message
Old Post
Frank Swarbrick
06-07-05 01:55 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Cobol archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:40 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.