Friday, 23 August 2013

9,000 char string in MYSQL column - which datatype to use?

9,000 char string in MYSQL column - which datatype to use?

I have a huge array (up to 9,000 characters) which I want to save in my
MYSQL database. I am going to encode it as a JSON using json_encode().
I am trying to determine the best data type in which to save it. From the
MYSQL documentation from what I understand, row memory limits are 65,535
bytes, with varchar being able to be up to 65,535 bytes itself. So at most
my 9,000 character JSON string could at most takeup 27,000 bytes with 3
characters per byte leaving me well under the 65k limit for the entire
row.
With this information I am led to believe varchar(9,000) should do the
trick, but I am a novice so I am not sure.
Can I use varchar(9,000) to save my JSON string or would there be a more
efficient data type?
Thanks.
*Note: This JSON information is dynamic, and text based, creating files
and reading / writing to them is not a option, I really want to accomplish
this within MYSQL's limits.

No comments:

Post a Comment