Re: CHAR vs VARCHAR w/TOAST

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: CHAR vs VARCHAR w/TOAST
Дата
Msg-id 29569.991665594@sss.pgh.pa.us
обсуждение исходный текст
Ответ на CHAR vs VARCHAR w/TOAST  ("Brent R. Matzelle" <bmatzelle@yahoo.com>)
Список pgsql-general
"Brent R. Matzelle" <bmatzelle@yahoo.com> writes:
> Does this mean that scanning is just as fast using VARCHAR
> as CHAR?  I was always taught to use CHAR on columns that I
> needed speedier search results.  What are the facts?

See recent discussions on this point.  There is no speed advantage to
CHAR() --- there never was more than a minuscule advantage to it in
Postgres, and that's now gone entirely.  However, if you are taking
naturally variable-width data and forcing it into CHAR(n) via
blank-padding, then you are paying very real costs in disk space and
I/O time for all those extra blanks.

To me, the bottom line is: use the data type whose semantics fit your
data (for textual data, that could be char(n), varchar(n), or text,
depending on what you want to enforce about length limits).  Anything
else is at best micro-optimization and more likely folly.

            regards, tom lane

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

Предыдущее
От: Francesco Casadei
Дата:
Сообщение: Re: PostgreSQL security concerns
Следующее
От: Lamar Owen
Дата:
Сообщение: Re: 7.1.2 packaging