I know the principle of using the smallest data type possible, but I wonder if this would apply to TEXT / MEDIUMTEXT / LONGTEXT in MySQL? Is there a performance issue if I use LONGTEXT instead of MEDIUMTEXT? I've found the question What is the disadvantage to using a MySQL longtext sized field when every entry will fit within a mediumtext sized field? but I think this isn't the answer to the performance question?
Is it just a matter of a bit more storage for LONGTEXT?
When should I prefer MEDIUMTEXT to LONGTEXT?
The only difference is the length field in the row data. Using MEDIUMTEXT
instead of LONGTEXT
saves 1 byte per record. If you have 100 million records, that saves 100 MB. There was a time when that was a significant amount of disk space.
The difference could also be significant if you're running up against the size limit for database rows. The text of *TEXT
data is stored in files external to the table data, so it doesn't count against the limit, but I believe the size field is in the table so it does count.
But if neither of these is an issue, go ahead and use the largest type, to future-proof your schema.