MySQL TEXT或VARCHAR

9

我们有一个非常大的历史表格,其中包含一列最多500个UTF8字符,而且磁盘空间增长得非常快!

我们每天至少有200万行...我们想知道哪个更好(主要是在存储方面,但也涉及性能)?TEXT还是VARCHAR(512)?


1
http://www.pythian.com/news/7129/text-vs-varchar/ - George Johnston
3个回答

11

从存储和性能两个角度考虑,VARCHAR可能更适合您的情况。请查看此经常转载的文章


2
这是有用的信息;我认为一般来说,varchar通常是更好的选择。

1

来自MySQL手册:

In most respects, you can regard a BLOB column as a VARBINARY column that can be as large as you like. Similarly, you can regard a TEXT column as a VARCHAR column. BLOB and TEXT differ from VARBINARY and VARCHAR in the following ways:

There is no trailing-space removal for BLOB and TEXT columns when values

are stored or retrieved. Before MySQL 5.0.3, this differs from VARBINARY and VARCHAR, for which trailing spaces are removed when values are stored.

On comparisons, TEXT is space extended to fit the compared object,

exactly like CHAR and VARCHAR.

For indexes on BLOB and TEXT columns, you must specify an index

prefix length. For CHAR and VARCHAR, a prefix length is optional. See Section 7.5.1, “Column Indexes”.

BLOB and TEXT columns cannot have DEFAULT values.

http://dev.mysql.com/doc/refman/5.0/en/blob.html


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接