Reputation:
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?
Upvotes: 4
Views: 4690
Reputation: 300669
Depends on the column type to some extent.
Variable sized columns (such as varchar(n)
) will only use 4 extra 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.
Upvotes: 2
Reputation: 3391
I would like to add that although empty columns take up space (as mentioned in the other answers), when dealing with a big db, adding a column is not an easy task. So sometimes, it's good to have an additional column ready, even if it's just for future use.
Upvotes: 2
Reputation: 130847
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?
Upvotes: 2