>>>Hi Sergey,
>>>>The index "design" is bad. Try
SET EXACT OFF
>>>SEEK transform(13609,'99999999')
>>>SCAN WHILE transform(de_sysnum,'99999999')+transform(de_histnum,'9999') = ;
>>transform(13609,'99999999');
>>> FOR de_sysnum == 13609
>>> **** Do something
>>>ENDSCAN
>>>...
>>>>>active index is:
>>>>>transform(de_sysnum,'99999999')+transform(de_histnum,'9999')
>>>
>>>I'ld have proposed
>>>
SET EXACT OFF
>>>SEEK transform(13609,'99999999')
>>>SET EXACT ON
>>>SCAN rest WHILE de_sysnum = 13609
>>> **** Do something
>>>ENDSCAN
>>>Since the controlling index already forces the order. Am I overlooking something ?
>>>The dsik movement optimization which is the main optimization should still be identical,
>>>but why the 2 checks ? And "==" used with numerical fields was definitly slower
>>>in tests done a long time ago - haven't checked recently.
>>>
>>
>>
>>Thomas,
>>
>>Yes, you did ovelook that index is created from 2 fields and in a such way that you cannot tell from the index key where the first field ends and the second starts. The seeks only brings you to the records which index key starts with '13609' but it could be from '1360' + '9' or '13609' + '75'. The for clause insures that only records with de_sysnum = 13609 are processed. With SET EXACT ON and SCAN rest WHILE de_sysnum = 13609 all records that we want to process will be excluded.
>
>Sergey, transform(de_sysnum,'99999999') is a fixed lenght key.
>
>? LEN(transform(13609,'99999999'))
>
Right you're. Somehow I missed a format clause that makes expression fixed lenght. A simple SEEK with SCAN WHILE as Thomase suggested would work. BTW, the REST clause is not necessary because it's default for SCAN WHILE.
--sb--