Subject Re: [ib-support] Please help me with query plan
Author Andrew Guts
Daniel Rail wrote:

>Try reorganizing your query.
>
>Here's how I would write it:
>
>select sum(x.Price*x.Qty/d.Rate)
> from xfers x
> inner join docs d on ((x.docid=d.id) and (d.customerid=x.dstid))
> where (x.dstid=:id)
> and (d.DepID=:dep)
> and (d.DocDate<CURRENT_TIMESTAMP)
> and exists (select *
> from optypes t
> where (t.id=x.typeid)
> and (t.factor<>0))
>
>

Default plan is the same for your version. I agree, reorganizing query
is a better way.

Thank you.