tags:

views:

246

answers:

2

i have a few columns that i know won't be used initially. is it a good practice to add columns only when needed or just leave those extra columns there?

is it just a little more space in the header or every row?

A: 

Depends on the column type to some extent.

Variable sized columns (such as varchar(nn)) will only use 4 bytes (approx) per row.

I would add columns only when required, since it is less likely that redundant columns will be added and never removed.

Mitch Wheat
even when they are empty? or nullmy question should be does empty or null fields take up space
Yes. Empty and NULL columns do take up space. SQL Server 2008 has new row compression for sparse tables, i.e. those with lots of NULL columns...
Mitch Wheat
Unless you have Huge tables, I think the maintainability issue of redundant columns is more important that space concerns. I often see DBs with may unused columns but developers are nervous to remove in case they are used somewhere else (such as export to another system etc)
Mitch Wheat
A: 

Yes, they do still take up space, if only a couple bytes per row (depends on the column type). If you're not going to use them until later, what good is it to keep them there?

musicfreak