Subject Re: [firebird-support] Re: query plan
Author Ivan Prenosil
Hi Set,

could you, please, post any example of sql statment
with IN(<subquery>) clause, which will get different/better
plan after rewriting it to use EXISTS clause ?

Thanks,
Ivan


>From: "Svein Erling"
> > SELECT SUM(encomendas.qtdtotal) FROM encomendas
> > WHERE id in (SELECT idenc FROM encgrupolin WHERE id=:xpto)
> >
> > Plan
> > PLAN (ENCGRUPOLIN INDEX (RDB$FOREIGN214,FK_ENCGRUPOLIN_ENCOMENDAS))
> > PLAN (ENCOMENDAS NATURAL)
...
> I know it might still do, I have not changed from 1.0 yet). For 1.0 it
> is therefore better to change this kind of query to
>
> SELECT SUM(encomendas.qtdtotal) FROM encomendas
> WHERE exists (SELECT * FROM encgrupolin
> WHERE encgrupolin.idenc = encomendas.id and
> encgrupolin.id=:xpto)
...