patternsqlMinor
MySQL: TEXT and VARCHAR Speed and Size
Viewed 0 times
sizetextvarcharmysqlandspeed
Problem
Does varchar and Text affect the database size?
Also, do they differ in speed?
I have a Database that will have at least 4000 to 8000 new rows per day.
I'm quite worried about how it performs. This is my first time setting up an Enterprise-grade system and database though.
Also, do they differ in speed?
I have a Database that will have at least 4000 to 8000 new rows per day.
I'm quite worried about how it performs. This is my first time setting up an Enterprise-grade system and database though.
Solution
Use what you need and don't worry about performance. But use only what you need. There are minor inefficiencies in saying
Here's why: If a
A related issue:
TEXT when VARCHAR(255) will suffice. Ditto for VARCHAR(255) when VARCHAR(20) will suffice.Here's why: If a
SELECT needs build a tmp table (eg, for ORDER BY), it first tries to use a MEMORY tmp table (better), but may have to fall back on a MyISAM table (slower). Any kind of TEXT or BLOB forces MyISAM. VARCHAR turns into CHAR (for the tmp table); if the tmp table gets too big for MEMORY, it converts to MyISAM.TINYTEXT is probably never a good idea.A related issue:
CHAR(...) is useful only if the field is (1) constant length, and (2) declared with the appropriate CHARACTER SET. A common mistake is putting a fixed-length hex string in a utf8 CHAR field.VARCHAR and TEXT (all sizes) have a small length field prefixing them. This is relatively insignificant.Context
StackExchange Database Administrators Q#114535, answer score: 3
Revisions (0)
No revisions yet.