February 28, 2014 at 9:11 am
For a bit field, is using
WHERE mybit = 0x0
faster than
WHERE mybit = 0
I am being told to use 0x0 but am not yet convinced.
Thanks!
February 28, 2014 at 9:48 am
smrtstpetesmith (2/28/2014)
For a bit field, is usingWHERE mybit = 0x0
faster than
WHERE mybit = 0
I am being told to use 0x0 but am not yet convinced.
Thanks!
Why don't you do some performance tests?
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
February 28, 2014 at 9:55 am
I am but my results thus far are statistically insignificant...
February 28, 2014 at 10:11 am
smrtstpetesmith (2/28/2014)
I am but my results thus far are statistically insignificant...
I would surprised if there is any difference. Throw together a few million row test table and give it a whirl. I suspect it will be the same.
What is the rationale you are being told to use 0x0 instead of 0? Often people get ideas about performance and they stick with them even if there is nothing to back it up. I have a feeling this may be one of those situations.
If you do end up using 0x0 you should probably add a comment about what that is for others who stumble across your code in the future and wonder what it is trying to accomplish. 😉
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
March 3, 2014 at 9:53 am
smrtstpetesmith (2/28/2014)
For a bit field, is usingWHERE mybit = 0x0
faster than
WHERE mybit = 0
I am being told to use 0x0 but am not yet convinced.
Thanks!
I suspect the person who told you that assumed it would avoid an implicit conversion in the execution plan. So the way to tell is to try both and compare the plans.
I've just done that with a very simple test, and the results were the other way around.
Using 0x0 resulted in an implicit conversion to bit, whereas using 0 did not.
The conversion is performed just once against a constant, so has zero impact on cost. Both queries had identical cost, even down to 7th decimal place.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply