Subject Re: Slow IN operator
Author jasajona
Thank you for help!

I found great solution how to make my query fast.

So I have table with tree structure. Wrote stored procedure for
getting all sub branches (in my case is tee of departments). I had to
select some records from other table with department and all it's sub
departments (no matter how many levels there are). Finally I reduced
execution time about 60x by using "join" instead of "in".

select
*
from table1
join GetAllSubDepartments(:MasterDepartmentID) on
table1.DepartmentID = GetAllSubDepartments.DepartmentID

That's it! I think now my stored procedure is executed just one time.
B.t.w. "exists" made no improvment in my case.