Subject | Re: [firebird-support] Re: derived table within EXISTS (was: Different performance Superserver VS. Embeded ?) |
---|---|
Author | Milan Babuskov |
Post date | 2008-02-25T17:06:24Z |
danyschaer wrote:
select p.PROC, p.EXP1 as EXPE, p.ACTO, p.DEMA, p.OBSE, t.DSCR as D_TPRO
from PROC p
join MOVI m on p.PROC = m.PROC and m.TIPO = 'B'
left join TPRO t on p.TPRO=t.TPRO
order by lower(p.ACTO);
Make sure you have indexes on PROC(PROC) and MOVI(PROC,TIPO) and it
should fly.
Since FB2.1 allows to create indexes on expressions, it might also be a
good idea to create index on: lower(PROC.ACTO)
--
Milan Babuskov
http://www.flamerobin.org
> Preparing query: select p.PROC, p.EXP1 as EXPE, p.ACTO, p.DEMA,Try this one:
> p.OBSE, t.DSCR as D_TPRO
> from PROC p
> left join TPRO t on p.TPRO=t.TPRO
> where exists(select * from MOVI m
> where p.PROC = m.PROC
> and m.TIPO = 'B')
> order by lower(p.ACTO)
select p.PROC, p.EXP1 as EXPE, p.ACTO, p.DEMA, p.OBSE, t.DSCR as D_TPRO
from PROC p
join MOVI m on p.PROC = m.PROC and m.TIPO = 'B'
left join TPRO t on p.TPRO=t.TPRO
order by lower(p.ACTO);
Make sure you have indexes on PROC(PROC) and MOVI(PROC,TIPO) and it
should fly.
Since FB2.1 allows to create indexes on expressions, it might also be a
good idea to create index on: lower(PROC.ACTO)
--
Milan Babuskov
http://www.flamerobin.org