I have contact table, which contain Ids
, name
, email
, delete
and other columns. Have records around 5 Million.
Writing below query, then facing no issues getting results with in limits:
execution time: <2 secs.
Select row_id
from contact
where row_id in (select row_id
from Contact_details
where email in ('abc@abc.com', 'xyz@xyz.com'))
but when converting this query with OR clause for at-least default selection of 0 row_id it starts taking too long.
execution time: >120 sec.
Select row_id
from contact
where row_id=0 **OR** row_id in (select row_id
from Contact_details
where email in ('abc@abc.com', 'xyz@xyz.com'))
I have tried union rather than using OR, yes that improves performance but this is an application generated query, so is there a way through which this query can be improved without using union or union all.