Re: seeking advise on char vs text or varchar in search table

Поиск
Список
Период
Сортировка
От Gregory Stark
Тема Re: seeking advise on char vs text or varchar in search table
Дата
Msg-id 87abwva5yr.fsf@oxford.xeocode.com
обсуждение исходный текст
Ответ на Re: seeking advise on char vs text or varchar in search table  (Jim Nasby <decibel@decibel.org>)
Список pgsql-performance
"Jim Nasby" <decibel@decibel.org> writes:

> AIUI, char, varchar and text all store their data in *exactly* the same way in
> the database; char only pads data on output, and in the  actual tables it still
> contains the regular varlena header. The only  reason I've ever used char in
> other databases is to save the overhead  of the variable-length information, so
> I recommend to people to just  steer clear of char in PostgreSQL.

Everything you said is correct except that char actually pads its data on
input, not output. This doesn't actually make a lot of sense since we're
storing it as a varlena so we could pad it on output and modify the data type
functions to pretend the spaces are there without storing them.

However it would only make a difference if you're storing variable length data
in a char field in which case I would 100% agree with your conclusion and
strongly recommend using varchar. The only reason I would think of using char
is when the data should always be the same length, like a SSN or md5hash or
something like that. In which case it's purely for the self-documenting
notational convenience, not any performance reason.

--
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com


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

Предыдущее
От: "Luke Lonergan"
Дата:
Сообщение: Re: What`s wrong with JFS configuration?
Следующее
От: Cosimo Streppone
Дата:
Сообщение: Re: What`s wrong with JFS configuration?