4 ms·
Why you are being down voted: As far as I know in most databases TEXT and BLOB types have no "arbitrary" length parameters but are stored at the end of the dat
by KekDemaga 9y ago
Why you are being down voted: As far as I know in most databases TEXT and BLOB types have no "arbitrary" length parameters but are stored at the end of the database file making access slower especially on spinning rust, VARCHAR(x) can only be x characters long but is stored inline with the table so it's much faster. If you know the length of a string won't exceed a relatively small number of characters VARCHAR is the right tool for the job.
- lobster_johnson 9y agoFun fact: Postgres is one of the few databases to do this right. "varchar" is just an alias for the "text" data type, which has a limit of 2GB (last I checked). A small amount of text is stored inside the row, and the overflow is compressed and stored in a series of linked child rows. The system is called TOAST, and quite fast. So the underlying storage is completely abstracted, and setting a limit doesn't impact storage; it only enforces a limit on what input is allowed. MySQL's text type, on the other hand, is like a binary blob and has (last I checked) different semantics than the varchar type.