MySQL DBA
MySQL DBA

Reputation: 5812

Does Mysql Text DataType reserves any memory space

I want to know if mysql TEXT data type reserves any space even if there is no data in that row?

I am little confuse. Can anyone provide me any input on this.

Upvotes: 10

Views: 3485

Answers (1)

Eric
Eric

Reputation: 95133

Typically, no. text columns are actually stored away from the row, so they don't take up space on the row, per se. Instead, the row keeps a pointer to the text column (which does take up space, but only 4 bytes-ish (depends on the system) a row), but the text column itself will remain empty until you populate it.

Now, varchar columns will allocate space for their max at insertion, but only take up the space needed by its contents. char columns, however, will always use the space specified. So, here's what each column looks like with the phrase "waffles":

varchar(15): 'waffles'
char(15):    'waffles        '
text:        'waffles'

Hopefully, this helps.

Upvotes: 22

Related Questions