views:

123

answers:

3

Thought I would ask the knowledgeable StackOverflow community a question that was on my mind today and I can't seem to find an answer.

Is there any performance difference or advantage between an "IN" or using "OR"?

Ie. Is

SELECT type FROM types WHERE typecat IN ('abc', 'def')

better than

SELECT type FROM types WHERE typecat = 'abc' OR typecat = 'def'

Adding: Using SQL Server 2008

+1  A: 

No, there is no performance difference. The optimizer takes care of it.

Otávio Décio
+2  A: 

This depends entirely on the SQL product you're using, which you haven't stated. One RDBMS that I use regularly cannot use indexes for the OR version.

Larry Lustig
Care to reveal the name of said RDBMS?
Allon Guralnek
R:Base (blast from the past).
Larry Lustig
Sorry, using SQL Server 2008.
Mark Kadlec
+1  A: 

If I recall correctly, SQL Server converts the IN statement you have into the OR statement.

Austin Salonen