Subject | Query Plan (index use on IN clause) |
---|---|
Author | cpis20022002 |
Post date | 2004-01-21T11:52:03Z |
Hi Svein
Thanks for your anwser
but
SELECT SUM(encomendas.qtdtotal) FROM encomendas
WHERE exists (SELECT * FROM encgrupolin
WHERE encgrupolin.idenc = encomendas.id and
encgrupolin.id=:xpto)
still don't use index on table encomendas
I use Firebird 1.5 RC7
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)
And yes if I replaced my subselect with constants.
eg.
SELECT SUM(encomendas.qtdtotal) FROM encomendas
WHERE encomendas.id in (320,318)
then the plan
is
SELECT SUM(encomendas.qtdtotal) FROM encomendas
WHERE encomendas.id in (320,318)
Any sugestion?
Thanks again
Agostinho
cpis@...
Thanks for your anwser
but
SELECT SUM(encomendas.qtdtotal) FROM encomendas
WHERE exists (SELECT * FROM encgrupolin
WHERE encgrupolin.idenc = encomendas.id and
encgrupolin.id=:xpto)
still don't use index on table encomendas
I use Firebird 1.5 RC7
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)
And yes if I replaced my subselect with constants.
eg.
SELECT SUM(encomendas.qtdtotal) FROM encomendas
WHERE encomendas.id in (320,318)
then the plan
is
SELECT SUM(encomendas.qtdtotal) FROM encomendas
WHERE encomendas.id in (320,318)
Any sugestion?
Thanks again
Agostinho
cpis@...