Subject RE: [firebird-support] Re: derived table within EXISTS (was: Different performance Superserver VS. Embeded ?)
Author Leyne, Sean
Dany,

> Well, I thougth about how selective is MOVI.PROC so I did a few tests
> adding the "distinct" clause, even with your approach, but same
results:
>
> select p.PROC, p.EXP1 as EXPE, p.ACTO, p.DEMA, p.OBSE, t.DSCR as
D_TPRO
> from PROC p
> left join TPRO t on p.TPRO=t.TPRO
> where exists(select distinct PROC from MOVI m
> where p.PROC = m.PROC
> and m.TIPO = 'B')
> order by lower(p.ACTO)


Try:

Select
p.PROC, p.EXP1 as EXPE, p.ACTO, p.DEMA, p.OBSE, t.DSCR as D_TPRO
from (
SELECT
distinct PROC
from MOVI
where
TIPO = 'B')
) m
JOIN PROC p on p.PROC = m.PROC
left join TPRO t on p.TPRO=t.TPRO
order by
lower(p.ACTO)


Sean