November 2, 2009 at 12:24 pm
All,
I just started a short contract to help optimize and tune the queries and database for a small company that sells a web service.
I've noticed that the developer(s) use the following contruct almost as a standard:
where a.ColumnName IN (4)
I have conducted a few tests to determine if this is slower than
where a.ColumnName = 4
The results are inconclusive; sometimes "IN" is faster, sometimes "=" is faster.
What do you think?
TIA,
Mike
November 2, 2009 at 12:28 pm
Take a look at the execution plan. SQL will usually turn a single-value In into an equality test. The only time it doesn't, that I know of, is if there's an execution plan already in place for multiple values, and it uses that.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply