Subject | Re: [firebird-support] Re: Count in Join slowly when using 'in' |
---|---|
Author | Gary Benade |
Post date | 2005-02-14T16:36:28Z |
> I tried to rewrite it as:You seem to have the logic of the join turned around. try this
> Select Count(*) From Employee E Where EmployerId In (Select Id from
> Employer R Where R.CityId=(10,20,30))
Select Count(*) From Employer R
Inner Join Employee E On R.EmployerId=R.Id
where R.CityId In (10,20,30)
It should use all indexes as expected because firebird can use the cityid
index of employer to narrow the resultset and then use the employerid index
on employee to join things up.
FWIW
Gary