Friday, February 10, 2012

Bit Field vs. Integer with Nulls

If I have a field where 99.9% of the time the answer is going to be "No", would I be better, in terms of disk space, using:

A bit field

OR

A tiny int field, with a NULL for the 99.9% that are "NO", and a 1 for those that are "YES".

I'm using SQL Server 7.0.

My application developer has no preference.

Thanks.How much data are we talking about?

Also What is the field for?

Do you have to display the data?

I'd go with...

CREATE TABLE myTable99(Col1 char(3) DEFAULT('NO') CHECK(Col1 IN ('NO','YES')))|||Roughly 8000 records a month. The field is used to identify those records that are going to be non-billable, which is a very small percentage of the time.

The field itself will never appear on any report; it will determine if the particular record should appear on the standard report, or if it will be moved to a special report.|||Brett dude! You'd seriously store "No" and "Yes" in the database?

Excesive verbosity!

"Y" or "N", or 1 or 0 thank you!

I don't believe that a single bit field is going to take any less space than a smallint. I think you have to have several bit fields grouped in your table to realize any space savings.|||Yo,

Blind dude

You'd seriously prefer to perform conversions for display purposes for only 8k rows a month?

SELECT CASE WHEN Col1 = 1 THEN 'YES' WHEN Col1 = 0 THEN 'NO' END

This is like using a surrogate...no thanks

So, you're saving 16k a month....let's through a party...

No comments:

Post a Comment