VARCHAR vs TEXT performance when data fits on row

前端 未结 4 1418
面向向阳花
面向向阳花 2020-12-30 10:40
mysql> desc temp1;
+-------+--------------+------+-----+---------+-------+
| Field | Type         | Null | Key | Default | Extra |
+-------+--------------+------+         


        
4条回答
  •  天涯浪人
    2020-12-30 11:13

    TEXT type will be always slower than VARCHAR because those types have different methods of storage. VARCHAR field stored in the table with all columns but TEXT stored differently. Each TEXT value is a separate object. It means if you want to do something with TEXT value MySQL will make additional operations to get that object.

    Quote from the official documentation:

    Each BLOB or TEXT value is represented internally by a separately allocated object. This is in contrast to all other data types, for which storage is allocated once per column when the table is opened.

提交回复
热议问题