0

I am using MySQL. I have a query as shown below :-

Select col1,col2,col3...,coln from table a 
left join table b ON a.id = b.id
left join table c on a.id = c.id
where a.id NOT IN (1,2,3)

Above query worked perfectly fine returning results in 5 seconds. It did not return any results for which a.id is NULL I also wanted to include rows who have a.id is null. So I updated my query to include that

Select col1,col2,col3...,coln from table a 
left join table b ON a.id = b.id
left join table c on a.id = c.id
where a.id NOT IN (1,2,3) or a.id is NULL

But I guess, I am doing something wrong as query is running for quite a long time and then I am breaking the query.

Could any body please let me know why is there sudden decrease in performance?

I guess it is because of adding a.id is NULL, If that is the case, how can I include that in my condition to not affect performance.

Thanks

UPDATE

Not sure if relevant, but, in MYSQL output window, when I run this query, DUration/Fetch shows as .050 sec/ ?

Meaning Duration is just .05 sec but fetch is what is taking the long time.

Neil
  • 1,715
  • 6
  • 30
  • 45

0 Answers0