Reputation: 8055
Anybody knows how MySql allocates memory for "text" and "blob" in case i'm inserting smaller data than the max size of the column ?
For example, What happens when i insert 50K string into a "text" column? Is the entire 65K column allocated ?
Upvotes: 1
Views: 1343
Reputation: 1551
The TEXT data type comes in four different sizes *TINYTEXT *TEXT *MEDIUMTEXT *LONGTEXT
differing in the maximum length of values they can store. All are variable-length types, so an individual value requires storage equal to the length (in characters) of the value, plus 1 to 4 bytes to record the length of the value. Trailing spaces are not removed or added for storage or retrieval.
For variable-length (VARCHAR, TEXT) columns, MySQL allocates only the required amount of space for each stored value.
i.e. For Text datatype Number of characters
+ 2 bytes
and has Max length upto 65,535 characters
Upvotes: 1