Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: In Operator


Message #1 by "Stahler, Wes" <stahlerw@o...> on Thu, 18 Jul 2002 15:30:04 -0400
Jeff,Wes,
	the optimiser in MS SQLServer expands your IN operator into OR(s),
you're talking of a couple of nanoseconds.

	IN

	SQL Server Execution Times:
   CPU time = 16 ms,  elapsed time = 1622 ms.

	OR

SQL Server Execution Times:
   CPU time = 16 ms,  elapsed time = 2074 ms.

	CPU times identical, check out the Execution plan.

Nick

-----Original Message-----
From: Jeff Mason [mailto:jeffm.ma.ultranet@r...]
Sent: 18 July 2002 22:16
To: sql language
Subject: [sql_language] RE: In Operator


I doubt that you could measure the difference in performance (though I have
never tried). Both shortcut evaluation when the result has been determined.
I think IN is easier to read and maintain, especially as the number of
possibilities increases.

viz:

	... State IN ('CA', 'MA', 'NY', 'TX') ...

vs:

	... State ='CA' OR State ='MA' OR State ='NY' or State='TX' ...

Adding another state to the list seems easier with the IN operator.

I use OR when I have a couple or three conditions, IN for more than that,
but really IN is mostly used for subqueries.

YMMV.

--
Jeff Mason                      Custom Apps, Inc.
Jeff@c...
-----Original Message-----
From: Stahler, Wes [mailto:stahlerw@o...]
Sent: Thursday, July 18, 2002 3:30 PM
To: sql language
Subject: [sql_language] In Operator


I was recently told that a series of OR statements was more efficient then
using the IN operator.
Can someone speak to the validity of this statement?

Thanks,
Wes

--- Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 




*********************************************************************
This message and any attachments are confidential and should only be
read by those to whom they are addressed. If you are not the intended
recipient, please contact us, delete the message from your computer 
and destroy any copies. Any distribution or copying without our prior
permission is prohibited. 

The Achilles Group does not accept legal responsibility for the 
contents of this message. The recipient is responsible for verifying 
its authenticity before acting on the contents. Any views or opinions 
presented are solely those of the author and do not necessarily 
represent those of the Achilles Group.

This email has been scanned by MAILsweeper and Sophos Anti-Virus 
products. However, The Achilles Group will have no liability for any 
viruses contained in this email or any attachment with this email.
*********************************************************************


  Return to Index