Subject Re: Count in Join slowly when using 'in'
Author sibo_oskam
I use the latest version of firebird 1.5.2.4731.

Sorry, it was a little more complicated than I suggested. I have to
deal with a cities as well. I tried to do something like:

Select Count(*) From Employee E Inner Join Employer R On
(E.EmployerId=R.Id) Where R.CityId In (10,20,30)

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))

It is just as slow and it don't uses the index.

I have:
index on Employer on cityid and
index on Employee on employerId

I have to add that if you just instead of the last in part:
'R.CityId=20' it turns out it is not optimized as well.

Both subqueries:
Select Id from Employer R Where R.CityId=(10,20,30)
Select * From Employee E Where E.EmployerId In (1001,1220,13230)
are optimized.
Can firebird not handle this, or what am I doing wrong?

Thanks,
Sibo