I understand the size/storage constraints of MySQL TEXT and MEDIUMTEXT fields, but I just wanted to make absolutely sure (before I sign off on a change) that I'm not looking at any adverse effects from converting a field with existing data from TEXT to MEDIUMTEXT.
My concerns are mainly performance, integrity, and disk storage.
Thanks
TEXT has a maximum length of 65,535 bytes—the same as VARCHAR. MEDIUMTEXT has a maximum length of about 16 megabytes. LONGTEXT has a maximum length of about 4 gigabytes.
The MEDIUMTEXT data object is useful for storing larger text strings like white papers, books, and code backup. These data objects can be as large as 16 MB (expressed as 2^24 -1) or 16,777,215 characters and require 3 bytes of overhead storage.
MEDIUMTEXT can store up to 16,777,215 characters i.e 16,777,215 bytes or 64MB of data. It is suitable for larger text strings like books, research papers, and code backup.
A TEXT column with a maximum length of 16,777,215 (224 − 1) characters. The effective maximum length is less if the value contains multibyte characters. Each MEDIUMTEXT value is stored using a 3-byte length prefix that indicates the number of bytes in the value.
With regard to the performance, integrity, and disk storage in the database layer, I wouldn't worry about it.
I can think of one possible impact:
Some client interface libraries pre-allocate a buffer to hold results, and they allocate enough memory for the largest possible value. The client doesn't know the length of the data before it fetches the data, so it must allocate enough space assuming the data might be as long as the data type supports.
Therefore the library would allocate 16MB per mediumtext
while it would allocate 64KB for a text
. This is something to watch out for if you have a low memory limit in your client layer. For instance, PHP has a memory_limit
config parameter for scripts, and the buffer allocated for data result sets would count toward this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With