Possible Duplicate:
SQL JOIN vs IN performance?
We're backed by SQL Server 2008. We have an application where a user can choose a list of items to search on, and they get all items based on those items. The two techniques we've used are:
SELECT * FROM mytable WHERE myval IN ('A', 'B', 'C')
and
INSERT INTO tempTable (tempvalue) ('A'), ('B'), ('C')
SELECT * FROM mytable m INNER JOIN tempTable t WHERE m.myval = t.tempvalue
The first option is easier, for sure, but performance is horrible once the user has chosen over 50 values. It's to the point where we're talking about scrapping the IN because performance degrades rapidly.
So, why does IN perform that badly? Is this typical or is it something specific with our setup?