Need guidance on Query optimizations. I have two tables userEvents and events
userEvents
id | userName | eventID
events
id | name
I need to find all the events name which has not eventID in userEvents
select id, name
from events
where id NOT IN ( select eventid
from userEvents
inner join events on events.id = userEvents.eventid
group by userEvents.eventID
)
I am able to get the result .I want to know how can I OPTIMIZE this query since there are large number of rows .