Skip to main content
1 of 4
Marco Demaio
  • 161
  • 1
  • 1
  • 6

Empty LONGTEXT or NULL?

In my MySQL DB I have one field called html_contents that contains all the html to be shown in a webpage. Obviously the html could be huge, and certaintly bigger than 64KB, therefor I decided to use LONGTEXT rather than VARCHAR.

When the field is not set or left empty would you say it is better (alias more efficient) for the DB to set it to NULL or to empty string?

I read this: When to use NULL and when to use an empty string? but it talks about empty strings in general probably small strings and not LONGTEXT. I was wondering if with LONGTEXT is a different story, maybe it saves a lot of space or time during queries to use NULL instead of leaving empty LONGTEXT around.

Marco Demaio
  • 161
  • 1
  • 1
  • 6