Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What is faster in a SQL Select Char or Integer?
Message
 
 
To
11/08/2011 11:05:25
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01520691
Message ID:
01520693
Views:
48
>>Hi,
>>
>>I am deciding on what type of field/column/expression to use for extracting records from a table. My choices are:
>>1. Char field (of about 10 to 20) (depends on the business rule) that will be empty ('') for certain records
>>2. Integer field that will have an entry 1000 (or some large number) for certain records.
>>
>>So the SQL Select will be approximately as following:
>>
>>1.
>>
>>select * from Mytable where <SomeWhereExpression>  and len(rtrim(ltrim(char_field))) > 0
>>
>>
>>2.
>>
>>select * from Mytable where <SomeWhereExpression>  and integ_field < 1000
>>
>>
>>Generally the size of the MyTable will be about 10,000 to 30,000 (just guess on my part).
>>
>>Which of the above (given that there is an index in SQL Server on both fields) will execute faster (generally)?
>>
>>TIA.
>
>
>The first I guess
>- integer is only 4 bytes to compare

Did you mean the second? E.g. I would expect the select based on integer field to be faster. If you're using SQL 2008, you can make a filtered index for either of the fields with the above condition and then both cases will be very quick.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform