Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Efficient counting of recs with duplicate key fields
Message
From
13/06/1999 13:01:34
 
 
To
13/06/1999 01:15:04
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00229225
Message ID:
00229255
Views:
22
Hi David ---

Cindy has a good way of doing it. Another would be:

SEEK vVal TAG KeyTagName
COUNT TO nDupes WHILE keyfield = vVal

This doesn't mess up your index order, is optimizable (well, that depends on your key expression), and should be faster as it doesn't create a cursor.


>I have a large table in which a small percentage of the records have identical values in a particular key field. What is the most efficient way to count the number of records having a particular value in the key field. If I'm only interested in a particular key value, searching by filtering seems like a pretty sexy way to do it, but do the realities of filter implementation indicate against it for large files?
>
>1) ordering off, count for keyname = value all
> (key is in active .cdx file)
>2) order by key, count for keyname = value all
>3) order by key, seek keyname = value, count for keyname rest
>4) ordering off, set filter to keyname = value then count all
>5) order by key, set filter to keyname = value then count all
>6) order by key, seek keyname, set filter to keyname = value
> then count all
>7) order by key, seek keyname, iterate a do loop to count
> while skipping
>8) something else I haven't thought of...
>9) Rushmore is so efficient that for a the trivial key expression
> given above, all of these are about the same.
------------------------------------------------
John Koziol, ex-MVP, ex-MS, ex-FoxTeam. Just call me "X"
"When the going gets weird, the weird turn pro" - Hunter Thompson (Gonzo) RIP 2/19/05
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform