Subject Re: [firebird-support] Query optimization - Why this plan ?
Author Ann W. Harrison
Arno Brinkman wrote:
> Hi Alexandre,
>
> ...FROM Empresa e
> JOIN Cliente c ON (e.EmpresaId = c.EmpresaId)
> ....LEFT JOIN Endereco en ON ((en.EmpresaID = c.EmpresaID) and (en.Tipo = 1))
> LEFT JOIN Estado es ON (es.EstadoID = en.EstadoID)
> WHERE
> e.Nome = 'Alexandre Benson Smith'
>
>>This query returns just one record, and I have a unique index on E.Nome
>>that is a varchar(40). Why the optimizer don't priorize the unique index
>>if I am searching for a specific value on that column ???
>
>
> I'm afraid you hit one of the limitations of the current optimizer (FB1.5).

Alexander, out of curiosity, what happens if you put the e.name
restriction into the "on" clause of the first join?

JOIN Cliente c
ON (e.EmpresaId = c.EmpresaId
and e.Nome = 'Alexandre Benson Smith')


Regards,


Ann