What an open ended question... :0)

Ok, it depends...

(1) If run a second time they will both appear to run faster
(When you
first run either (1) or (2) the proggie will have to be
loaded into
memory, the second time around it'll still be there, plus
it's highly
likely the data will be too)

(2) does the file in (1) have an index on it? If so, (1)
will be faster,

    UNLESS
    file (1) has very few items in it, and the straight-thru
process is
able to process the file incl reads, before the select in
(1) is
complete.

Of course, the fact that (2) has the IO penalty of a read,
immediately
means it will be slower. However, if (2) had the field being
tested as
part of its key, the read would be unnecessary, and the
whole program
would thrash (1)...

UNLESS
you run (2) on a 386 and (1) on a RS6000... ok, so that's
being Friday
afternoon-ish...

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: 17 June 2004 09:45
To: [EMAIL PROTECTED]
Subject: [U2] relative speed of Retrieve SELECT vs Basic
SELECT, LOOP
READNEXT,READ.


"Stevenson, Charles" <[EMAIL PROTECTED]>
wrote: <snips>
Which would you suppose is much faster: ...
      FOR I = 1 TO 100
         EXECUTE 'SELECT VOC WITH TYPE = "V" COUNT.SUP'
         LOOP WHILE READNEXT ID
            NULL ;* GOSUB DO.STUFF
         REPEAT
      NEXT I
...
or
...
      OPEN 'VOC' TO F ELSE STOP
      FOR I = 1 TO 100
      SELECT F
      LOOP WHILE READNEXT  ID
         READ REC FROM F, ID THEN
            IF REC[1,1]='V' THEN
               NULL ;* GOSUB DO.STUFF
            END
         END
      REPEAT
...
Notice how much less work #2 (seemingly) does:
...
Method 2 takes 2 or 3 times as longer to run than Method 1.
It's not
because VOC is a special file. I've tried it on other files,
big and
small. ... </snips>

It is my understanding that UniData (at least...don't know
about
UniVerse) cache's the SELECT in Method 1.  You can see this
from ECL by
timing a huge select, then CLEARSELECT, then re-issue the
original
select.  The second run will come back much quicker.

Also, Method 2 reads the block from the file and reallocates
the value
of "REC" for each iteration, while Method 1 reads each block
once and
parses for ID's.  Assuming 10-20 records per block
(recommended file
sizing from my UniData Admin trainer), that's a 10- to
20-fold savings
on disk reads.

--Tom Pellitieri
-------
u2-users mailing list
[EMAIL PROTECTED]
To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
[EMAIL PROTECTED]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to