Should I use blob or text for JSON in MySQL?

blob, mysql, mysql-json, text

Solution

`blob` is usually for things like images, binaries etc. `text` should be good enough for your case, or you can use `longtext` which has even bigger space capacity if that's really a concern.

Searching-wise, since you are storing `json_encode`'d stuff, you'll still need to call `json_decode` on it anyway for it to be useful in your application, I don't think choice of datatype matters in this case.

A better way is to normalize your database design instead of storing related stuff in one big string of json.

Problem

I am planning to store a `json_encoded` string on my database. I can't precisely tell the length its going to be, but I'm pretty sure it will be long. My concern is which field type I am going to use for this, is it `blob` or `text`? I prefer the one where I can save space as much as possible over fast searching, in any case I have other column where I should just index.

Original source