Re: Does a blank field take up disk space?
Date: Fri, 29 Jul 2016 21:17:56 -0400
Message-ID: <nngv7p$jqq$1_at_jstuckle.eternal-september.org>
On 7/29/2016 10:23 AM, bit-naughty_at_hotmail.com wrote:
> If I have a field, say "Price", and there has been nothing put into that field in a particular line (but there may be something in that field on *other* lines), I assume it doesn't take up space on the disk?
> (I have very little idea about what data structures MySQL uses to do its shit - what *is* it, anyway?)
>
>
> Thanks.
>
Now that I have more time to respond (sorry, I was pretty busy earlier but should have been more clear), I should add the amount of space taken depends on the storage engine you use. For instance, if you're using ISAM, the row has a bitfield header with one bit for each column to indicate whether the field is NULL or not. Fields are still stored in the database.
INNODB has a row header which has the offset of the column with the high bit of the header NULL if that field is NULL. If that is the case, the field does not need to be stored.
Fields can be fixed or variable length; for other than NULL fields in INNODB, fixed length fields always take up the amount of allocated space. Variable length fields have a length field (one or two bytes) followed by the amount number of bytes in the length field.
[Quoted] The real question here is - does it really matter? Unless you're talking hundreds of millions of rows, there are more critical concerns than the amount of disk space required.
-- ================== Remove the "x" from my email address Jerry Stuckle jstucklex_at_attglobal.net ==================Received on Sat Jul 30 2016 - 03:17:56 CEST