|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Between vs InI have a need for a criteria to be = 32 or 33 and wondered if BETWEEN 32 AND
33 would be faster than IN(32,33). This is an indexed field. Thanks. David When you timed this yourself, what was the result?
What did the query analyzer explain plans say? I'd bet the optimizer would alter your code to whatever it thinks is fastest (yes, sql server optimizer does do this). That said, I'd bet you wouldn't see a different in either approach. I'd use the IN clause because it is a direct comparison versus a math comparison. -- Show quoteRobbe Morris - 2004/2005 Microsoft MVP C# EggHeadCafe's RSS Search Engine http://www.eggheadcafe.com/articles/multisearch/default.aspx "David Chase" <dlch***@lifetimeinc.com> wrote in message news:e0%23qscwuFHA.2504@tk2msftngp13.phx.gbl... >I have a need for a criteria to be = 32 or 33 and wondered if BETWEEN 32 >AND 33 would be faster than IN(32,33). This is an indexed field. Thanks. > > David > I know it would have been faster to try it than to ask that question. The
best answer to performance questions is to try it out for yourself. We don't have access to your schema, your data and your hardware. -- David Portas SQL Server MVP -- Hi
as others suggested, you can test with execution paln, time etc. But include OR also, that is the best. IN may have additional ovehead. Regards R.D Show quote "David Portas" wrote: > I know it would have been faster to try it than to ask that question. The > best answer to performance questions is to try it out for yourself. We don't > have access to your schema, your data and your hardware. > > -- > David Portas > SQL Server MVP > -- > > > On Fri, 16 Sep 2005 23:06:02 -0700, R.D wrote:
>Hi Hi R.D.,>as others suggested, you can test with execution paln, time etc. >But include OR also, that is the best. >IN may have additional ovehead. IN(value, value, ...) is exactly equal to a set of OR conditions. Just check out the execution plan of a query that uses an IN condition. Best, Hugo -- (Remove _NO_ and _SPAM_ to get my e-mail address)
Other interesting topics
|
|||||||||||||||||||||||