Mark,
It's kind of hard to read exactly what you are trying to do in that code. You basically have an O(n
2) algorithm there. And (1.5x10^6)
2 is quite a bit bigger than (5x10^5)
2. And it may be even worse then O(n
2) depending on how the other two fields end up inside your looping structure.
The GO TOP is not rushmore optimizeable you should use a LOCATE instead. Changing ORDER etc might be better handled by using the same table under alternate aliases. There may even be a couple of SQL statements that can handle the operation.
Can you describe in words what your loop is doing? Maybe show a couple of records before and after processing?
>We use a SEEK, followed by a DO WHILE loop. Here's a psuedo-code description:
>
>SET ORDER TO nGroup
>
>DO WHILE nGroup = 0
> liRecno = RECNO()
> lcField1 = cField1
> SET ORDER TO cField1
> SEEK lcField1
> DO WHILE cField1 = lcField1
> IF (RECNO() <> liRecno) .AND. (nGroup > 0)
> *- This is a matching record, other than the one we're using..
> lnGroup = nGroup
> GO liRecno
> REPLACE nGroup WITH lnGroup
> EXIT
> ENDIF
> ENDDO
>
> IF nGroup = 0
> *- No match, just create a new group ID here...
> ENDIF
>
> SET ORDER TO nGroup
> GO TOP
>ENDDO
>
>It basically assigns the current record to a record that matches on one field. There are actually 3 fields used to match by, I left them out for clarity.