Subject Re: [firebird-support] Order by
Author Sandeep Chandra
Alan McDonald wrote:

>>I have a query which gets data from 2 tables. Number of records read is
>>45 without order by clause, as soon as I put order by clause it goes to
>>360. In both cases the profile says "Indexed Reads".
>>
>>This is slowing the server and all the workstations.
>>
>>Why is this happening? How do I fix this so that other workstations are
>>not slowed down.
>>
>>Regards
>>
>>Sandeep
>>
>>
>
>fascinating - but tell us the query, query plan, table structure,
>application language, connection libraries etc - tell us something so we can
>make an educated guess as to what is happening - on the face of it I'd say
>"impossible!"
>

Using Delphi, IBO (using queries not table)

here is the sql

select cln.*, anm.*
from "Client_Main" cln left outer join "Animal_Main" anm
on anm."Owner" = cln."Ref_Number"
where cln."FName" starting with 'SA'
order by cln."FName" desc

for First case (Records read 45)
Plan is [PLAN JOIN (CLN INDEX (CLN_BY_FNAME),ANM INDEX (Anm_By_Owner))]

for Seconf case (Records read 360)
Plan is [PLAN SORT (JOIN (CLN INDEX (CLN_BY_FNAME),ANM INDEX
(Anm_By_Owner)))]

Regards

Sandeep