Dan Waters
dwaters at usinternet.com
Wed Nov 21 16:24:40 CST 2007
John, >From what I remember (and have done) the use of an IN clause is the same as a sub query (or sequential queries). I have heard that a NOT IN clause is slow because all values must be compared against the NOT IN list. Dan -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of jwcolby Sent: Wednesday, November 21, 2007 3:05 PM To: dba-sqlserver at databaseadvisors.com; 'Access Developers discussion and problem solving' Subject: [dba-SQLServer] Optimizing queries with in() - SQL Server 2005 I have a lot of queries where I have to look for multiple values. I have been using an IN() clause but I am advised that is very slow. OTOH I built two queries that use an IN() in one query and a bunch of ORs in the other and over a 56 million record table they were both so fast I couldn't see the difference (Indexed column, containing values 1-9 and A-T (under 2 sec) Any comments? John W. Colby Colby Consulting www.ColbyConsulting.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com