May 12, 2006 at 11:01 am
I was under the impression that an 'IN' would be faster than an 'OR' statement, but I just did some timetesting and found the OR statement ran just a little bit faster.
Start 2006-05-12 09:47:22.773
--AND (lead_status_id = 3 OR lead_status_id = 4)
Finish 2006-05-12 09:47:24.680 1.907 TOTAL seconds
-------------------------------------------
Start 2006-05-12 09:51:21.230
and lead_status_id in (3,4)
Finish 2006-05-12 09:51:23.153 -1.923 TOTAL seconds
May 12, 2006 at 11:10 am
if the IN statement was running accross a bigger list, like in(SELECT X FROM SOME TABLE),
I would expect it should be faster, because it would bailout as true on the first occurance of where the result was true,
the equivilent OR would probably result in a table scan;
when comparing just two values, I'm not surprised the OR is a bit faster.
They are really close timewise, i bet if you repeated ti several times, the results might be even closer.
Lowell
May 12, 2006 at 11:29 am
Thanks for your help once again Lowell!!
May 12, 2006 at 9:19 pm
Both are bad.
Put your values into temp table and join it to the tables from your query.
_____________
Code for TallyGenerator
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply