Can someone please help with optimizing the below query. Initially I wanted to use the OR operator for the join since I want to join two columns in the one table with only 1 column in the other but my criteria is OR i.e., if any one of those match, go for the join. But that was causing the CPU to be at 100% so I now try the below code but that still is cuasing the CPU to reach 100%.
Please help with this query, perhaps there is a better way but I certainly cant seem to think of any.
from a (nolock)
right join b (nolock)
on a.id in (b.1b, b.2b)
where b.id not in ('DELETED', 'N/A')
where a.id is null