Reputation: 1198
I am trying to save some xml into my mysql-database. But these chunks of xml can vary from 1000 to 1000000 characters. How can I save this into my database without reserving 100kb for each string, even if it is only 1kb long?
Edit:
I have checked http://dev.mysql.com/doc/refman/5.1/en/storage-requirements.html They say, Text is stored in blocks of 2000 characters. Interesting is, that changing MEDIUMTEXT to LONGTEXT changes 22kb to 100kb. The textsize was the same, so it should remain on about 4000b (4kb)
Do you have any idea why this happens and how to prevent it?
Upvotes: 0
Views: 288
Reputation: 125865
MySQL's variable-length string types allocate only the space required for store the data (together with its length). In your case, you will need the MEDIUMTEXT
type to be able to store up to 1000000 characters.
Upvotes: 2