Choosing Fields for SORTING

Hi Everybody,
Will Progress compiler choose its own fields for SORTING the records or we need to specify fields explicitly using ...BY phrase.

If it chooses its own field for sorting how it chooses and if we give BY phrase will this override all the existing sorting fields chosen by Progress 4GL???

Thanks in advance...
 
If the ordering of a set of records matters for some reason then you should always make this explicit with a BY phrase.

If you do not specify sort order with a BY phrase you will get records in an undefined order.

In practice the undefined order is essentially the order that the index or indexes used returns records in. But that isn't actually guaranteed anywhere that I can think of and using USE-INDEX to force a sort order is kind of silly when a BY phrase exists for that very purpose and is much easier to read.
 
Thanks for your immediate reply. So you mean to say that we need to specify the field for sorting explicitly. How about the performance when we provide sort fields and without providing sort fields? Can you give a brief idea on this?

Thanks in advance...
 
Performance is, of course, potentially impacted. If the indexes used are not a good fit for the sort order specified then client side sorting will occur. BY is, however, only used as the next to last a tie-breaker in index selection (alphabetic order of index names is the last tie-breaker).

Generally speaking if the BY fields are a subset of the WHERE fields then the performance will be comparable to that of an unordered query. If the query uses efficient indexes then the performance will probably be good. If the query uses a poor indexes then performance will be bad.

Keep an eye on the SRT files in your -T area. If they are growing then you may have a client-side sorting performance issue.
 
Back
Top