Is there any performance difference on retrieving a bit or a char(1) ?
Just for curiosity =]
UPDATE: Suposing i’m using SQL Server 2008!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For SQL Server: up to 8 columns of type
BITcan be stored inside a single byte, while each column of typeCHAR(1)will take up one byte.On the other hand: a
BITcolumn can have two values (0 = false, 1 = true) or no value at all (NULL) – while aCHAR(1)can have any character value (much more possibilities)So really, it comes down to:
BITCHAR(1)I don’t think it makes any significant difference, from a performance point of view – unless you have tens of thousands of columns. Then of course, using
BITwhich can store up to 8 columns in a single byte would be beneficial. But again: for your “normal” database case, where you have a few, a dozen of those columns, it really doesn’t make a big difference. Pick the column type that suits your needs – don’t over-worry about performance…..