Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Scan...Endscan
Message
 
 
To
28/05/2000 21:06:27
Victor Lapid
Phil. Long Distance Tel. Co.
Manila, Philippines
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00374171
Message ID:
00374418
Views:
34
>Hi to all,
>
> I'm trying to use Scan Endscan on large tables but i do not know why it is so slow when my tables are already index so I opted to use DO WHIL !EOF() syntax. What's happening here? If I use SCAN ENDSCAN in small tables, the result is remarkably good. 3 to 5 seconds difference in processing whe I use DO WHILE !EOF().
>
> Any explanation on this?
>
> TIA.

As Cindy said, SCAN works better on tables that have no index tag set.

SCAN/ENDSCAN positions the record pointer to the first record that is physically in the table (it does not use open indexes). It then brute forces its way through the table to the end. If you have an index tag set, it can not rapidly go through the physical table; it must go through the index. Finding physical record 2 in the index could take a lot of overhead processing if the record were in the index near the end. Instead of a sequential search, the SCAN may be go from the top of the index to the bottom many, many times.

To avoid this, SET INDEX TO and then process the file using SCAN/ENDSCAN. If you must have an index tag set, use the SCAN WHILE !EOF(). The WHILE clause will force the SCAN to use the active index and the processing time should be about the same as if no tag were set.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform