Re: PSQL Data Type: text vs. varchar(n)

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: PSQL Data Type: text vs. varchar(n)
Дата
Msg-id 3535.1143782836@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: PSQL Data Type: text vs. varchar(n)  (Chris <dmagick@gmail.com>)
Ответы Re: PSQL Data Type: text vs. varchar(n)  ("Uwe C. Schroeder" <uwe@oss4u.com>)
Re: PSQL Data Type: text vs. varchar(n)  (Chris <dmagick@gmail.com>)
Список pgsql-general
Chris <dmagick@gmail.com> writes:
> kurt _ wrote:
>> My question:  Is a text field just a varchar(Integer.MAX_VALUE)?

> varchar has a max of 255 characters,

You must be using some other database ;-)

The current Postgres code has a physical limit of 1G bytes for any
column value (and in practice you'll hit the threshold of pain
performance-wise at much less than that).  The only real difference
between type "text" and type "varchar(N)" is that you'll incur runtime
overhead checking that values assigned to varchar columns are not any
wider than the specified "N".

My own take on this is that you should "say what you mean".  If you do
not have a clear application-oriented reason for specifying a particular
limit N in varchar(N), you have no business choosing a random value of N
instead.  Use text, instead of making up an N.

            regards, tom lane

В списке pgsql-general по дате отправления:

Предыдущее
От: Chris Travers
Дата:
Сообщение: Re: PSQL Data Type: text vs. varchar(n)
Следующее
От: "Uwe C. Schroeder"
Дата:
Сообщение: Re: PSQL Data Type: text vs. varchar(n)