Hi,
I have a query that looks like (variables are set before running the query):
select id
from tableA myA
where
a > @start_date
and a < @end_date
and a.userid not in (
select userid from userTable where age > myA.age
)
The purpose of the query has been made up, but the problem really exists. The userTable has about one million rows, so doing a "not in" takes a really long time. How could I speed it up? Is there some type of join that could be done to make it more efficient?
Thanks in advance.
I have a query that looks like (variables are set before running the query):
select id
from tableA myA
where
a > @start_date
and a < @end_date
and a.userid not in (
select userid from userTable where age > myA.age
)
The purpose of the query has been made up, but the problem really exists. The userTable has about one million rows, so doing a "not in" takes a really long time. How could I speed it up? Is there some type of join that could be done to make it more efficient?
Thanks in advance.