Subject Re: [firebird-support] Re: Count in Join slowly when using 'in'
Author Gary Benade
> I tried to rewrite it as:
> Select Count(*) From Employee E Where EmployerId In (Select Id from
> Employer R Where R.CityId=(10,20,30))

You seem to have the logic of the join turned around. try this

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