存储英语短语的理想 PostgreSQL 数据类型是什么?

What would be the ideal PostgreSQL data type for storing English phrases?

这可能是一个愚蠢的问题,但我想知道是否应该对包含英语短语的列使用 VARCHAR(n) 或 TEXT。我不确定的原因是因为我不知道最大长度,有些短语最多可以包含 15 个单词或更多。我想 VARCHAR(500) 会工作得很好,但我也在考虑最坏的情况。我读到 PostgreSQL 中 TEXT 和 VARCHAR(n) 之间没有性能差异。在这种情况下我应该选择 TEXT 吗?

文本没有限制,因此它可能是一个正确的选择,而且您对性能的看法是正确的:这是 postgres 文档:

There is no performance difference among these three types, apart from increased storage space when using the blank-padded type, and a few extra CPU cycles to check the length when storing into a length-constrained column. While character(n) has performance advantages in some other database systems, there is no such advantage in PostgreSQL; in fact character(n) is usually the slowest of the three because of its additional storage costs and slower sorting. In most situations text or character varying should be used instead.

但你必须知道它不是标准的 SQL。