Forum Moderators: open

Message Too Old, No Replies

Reserved Space

just a clarification..

         

ag_47

4:49 am on Oct 15, 2008 (gmt 0)

10+ Year Member



I always try to minimize data size when designing new tables, trying to combine/fit everything efficiently so as not to waste space. I got a little confused today, so need some clarification. Basically, when I declare the type/size of a field does it actually affect the disk size of the database (when it's still empty), or does this simple tell sql what the maximum is, but as long as less data is contained disk space is preserved. Say I create to fields like so

a) 'col1' varchar(64) NOT NULL
b) 'col2' varchar(250) NOT NULL

While they are empty, will the database occupy the same disk space?
If they both get filled with the same data, say '128.128.128.128', will the relative disk size change?
Basically, by declaring bigger fields do I simply get higher limits (which won't matter for smaller data)?

coopster

12:18 pm on Oct 15, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



It depends on the RDBMS, but here are some MySQL manual pages on the subject:

The CHAR and VARCHAR Types [dev.mysql.com]
Data Type Storage Requirements [dev.mysql.com]
Choosing the Right Type for a Column [dev.mysql.com]

ag_47

4:24 am on Oct 16, 2008 (gmt 0)

10+ Year Member



Thanks, that seems to clear some things up..
So I guess if I declare (a) and (b) like above, but never really exceed 50 characters in both, then the disk space used will be the same and the leftover (NULL?) part will just be empty. Am I right? And the only difference would be in the 'title' (or specification) of the columns, 64 & 255 respectively?

I'm using MySQL by the way, I believe I ended up sticking to MyISAM storage engine..