1

I'm curious if I declare a column to be, say, varchar(5000) and then start creating rows, but leaving that column with null values, how is memory allocated? Is the DB growing by 5000 bytes for every row? Or does it wait to allocate memory until a value actually is set?

Yevgeny Simkin
  • 27,946
  • 39
  • 137
  • 236

1 Answers1

1

you can find your answer here:

http://dev.mysql.com/doc/refman/5.6/en/storage-requirements.html

NULL in MySQL (Performance & Storage)

How much memory will be occupied by a null value in a DB?

MySQL: How much space does a NULL field use?

Community
  • 1
  • 1
Peeyush
  • 4,728
  • 16
  • 64
  • 92
  • hmm... I'm still unclear... if I'm using InnoDB and the value is NULL it looks like it takes L + 2 bytes... Is L the defined space (5k) or is L whatever the length of the data is (in this case 0)? – Yevgeny Simkin Nov 01 '11 at 19:32
  • according the documentation, it only require 2 bytes for your actuall null nvarchar – Turbot Dec 04 '11 at 03:40