TEXT和BLOB区别

BLOB is a binary large object that can hold a variable amount of data. The four BLOB types are TINYBLOBBLOB,MEDIUMBLOB, and LONGBLOB. These differ only in the maximum length of the values they can hold. The four TEXTtypes are TINYTEXTTEXTMEDIUMTEXT, and LONGTEXT. These correspond to the four BLOB types and have the same maximum lengths and storage requirements. See Section 11.7, “Data Type Storage Requirements”.

BLOB是二进制大object,可以存储更多的数据。BLOB类型有四种TINYBLOB,BLOB,MEDIUMBLOB和LONGBLOB,每种类型最大长度值不同。

TEXT有四种类型,TINYTEXT,TEXT,MEDIUMTEXT,LONGTEXT类型。

Instances of BLOB or TEXT columns in the result of a query that is processed using a temporary table causes the server to use a table on disk rather than in memory because the MEMORY storage engine does not support those data types (see Section 8.4.4, “How MySQL Uses Internal Temporary Tables”). Use of disk incurs a performance penalty, so include BLOB or TEXT columns in the query result only if they are really needed. For example, avoid using SELECT *, which selects all columns.

BLOB和TEXT在查询的时候会使用临时表,从而引起磁盘操作,因为内存型存储类型不支持TEXT和BLOB类型。

使用磁盘操作会引发性能下降,因此包括BLOB和TEXT列的查询,最好是需要才查询,避免使用SELECT * 操作

【参考资料】

1、http://dev.mysql.com/doc/refman/5.6/en/blob.html

2、http://imysql.com/2014/09/28/mysql-optimization-case-blob-stored-in-innodb-optimization.shtml

原文地址:https://www.cnblogs.com/gsblog/p/4019686.html