Database table schema design - varchar(n). Suitable choice of N

Posted by morpheous on Stack Overflow See other posts from Stack Overflow or by morpheous
Published on 2010-05-21T14:49:26Z Indexed on 2010/05/21 14:50 UTC
Read the original article Hit count: 160

Filed under:

Coming from a C background, I may be getting too anal about this and worrying unnecessarily about bits and bytes here.

Still, I cant help thinking how the data is actually stored and that if I choose an N which is easily factorizable into a power of 2, the database will be more effecient in how it packs data etc.

Using this "logic", I have a string field in a table which is a variable length up to 21 chars. I am tempted to use 32 instead of 21, for the reason given above - however now I am thinking that I am wasting disk space because there will be space allocated for 11 extra chars that are guaranteed to be never used. Since I envisage storing several tens of thousands of rows a day, it all adds up.

Question:

Mindful of all of the above, Should I declare varchar(21) or varchar(32) and why?

© Stack Overflow or respective owner

Related posts about sql