Reference for storage space usage. This page lists the disk space consumed by each data type, helping with capacity planning and schema optimization.
The following tables indicate the approximate data storage requirements for each data type.
Note that MEDIUMINT columns will require 4 bytes in memory (for example, in InnoDB buffer pool).
are stored using a binary format, with the integer and the fraction stored separately. Each nine-digit multiple requires 4 bytes, followed by a number of bytes for whatever remains, as follows:
In the descriptions below, M is the declared column length (in characters or in bytes), while len is the actual length in bytes of the value.
In some , not all characters use the same number of bytes. utf8 encodes characters with one to three bytes per character, while utf8mb4 requires one to four bytes per character.
When using field the COMPRESSED attribute, 1 byte is reserved for metadata. For example, VARCHAR(255) will use +2 bytes instead of +1.
Assuming a single-byte character-set:
MariaDB defaults to the MySQL format (by means of the variable). Microseconds have the following additional storage requirements:
For the InnoDB , and row formats, a number of bytes will be allocated in the record header for the nullable fields. If there are between 1 and 8 nullable fields, 1 such byte will be allocated. In the record payload area, no space will be reserved for values that are NULL.
For the , the overhead is 1 bit in the record header (as a part of the 1-byte or 2-byte "end of field" pointer). In that format, a NULL fixed-length field will consume the same amount of space as any NOT NULL value in the record payload area. The motivation is that it is possible to update in place between NOT NULL and NULL values.
In other formats, NULL values usually require 1 bit in the data file, 1 byte in the index file.
This page is licensed: CC BY-SA / Gnu FDL
6
3 bytes
7
4 bytes
8
4 bytes
,
len + 3 bytes
,
len + 4 bytes
Given M members of the set, (M+7)/8 bytes, rounded up to 1, 2, 3, 4, or 8 bytes
16 bytes
16 bytes
'12'
2 bytes
'12'
3 bytes
1 byte
2 bytes
3 bytes
4 bytes
8 bytes
FLOAT(p)
4 bytes if p <= 24, otherwise 8 bytes
8 bytes
See table below
BIT(M)
(M+7)/8 bytes
0
0 bytes
1
1 byte
2
1 byte
3
2 bytes
4
2 bytes
5
3 bytes
1 byte for up to 255 enum values, 2 bytes for 256 to 65,535 enum values
M × w bytes, where w is the number of bytes required for the maximum-length character in the character set
M bytes
len + 1 bytes if column is 0 – 255 bytes, len + 2 bytes if column may require more than 255 bytes
len + 1 bytes
len + 2 bytes
''
' '
2 bytes
''
1 byte
'1'
'1 '
2 bytes
'1'
2 bytes
3 bytes
3 bytes
8 bytes
4 bytes
1 byte
0
0 bytes
1,2
1 byte
3,4
2 bytes
5,6
3 bytes
'12'