>Hilmar
>
>>It seems it is the last SELECT statement that takes too long, right?
>>
>>Do you have indices on the most important expressions?
>
>Yes I have the table indexed (see line 2)
>
>>>Select RZSTOP
>>>Set Order To RGDSNum && RTE_NO+RTE_LET+DIRECTN+STR(SEQNO,4)+STR(NUMBER,
If you have an index on the combined expression, a SEEK on the combined expression would be extremely fast. On the other hand, this index would not be used to optimize the SELECT statement as you posted it. For example, an index on Field1 + Field2 would only be used if you include a
WHERE Field1 + Field2 = ...". IOW, the index has to exactly match part of the WHERE clause, or all of it.
>Well, as there could be many J rec's with the same RTE_NO + RTE_LET + DIRECTN (c.f. Composite PK), but, of course, incrementally differnnet SEQNOs, do you mean I should knock off the PK?
No, apart from the fact that you need it, the primary key has unique value, and will cause no problem. I mean to knock of indices that have only a few possible values.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)