Re: underlying structure: varchar vs. text

Поиск
Список
Период
Сортировка
От Mitch Vincent
Тема Re: underlying structure: varchar vs. text
Дата
Msg-id 00b601c0d4e0$b6487aa0$1251000a@windows
обсуждение исходный текст
Ответ на underlying structure: varchar vs. text  (pnews@modulo.org)
Ответы Re: Re: underlying structure: varchar vs. text  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
> I'm trying to store anywhere from a few words to a half page of text as a
> field in my table. A fellow db programmer told me that better than using a
> varchar is to break the message up into n pieces of size m (let's say
m=100),
>
> and make n (or n+1) varchar(m)s, and relate them together.

If the text needs to be stored together, there isn't anything wrong with
using a text type field. Keep in mind that in 7.0.3 there is an 8k limit on
text fields (unless you increased it at compile time) and that in any
PostgreSQL you can't directly index text fields (though there is some stuff
in contrib that can help)..

> He is worried that varchars allocate and hold space.

Do you mean many varchar fields will take up more space than a single text
field both holding the same information? I don't know for sure but I'd say
that's true -- it's probably a pretty small different though (well,
depending on what the total amount of data we're talking about is).

> I'm not sure if that is actually more efficient, nor do I know the limit
> of how big you can make a varchar.

I think I remember Tom saying it was around 2100 bytes. I could be pretty
far off on that though.

Oh -- Update to 7.1 if you can, it's *really* nice...

-Mitch


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

Предыдущее
От: Joel Burton
Дата:
Сообщение: Re: Newbie Question
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: Re: a primer on trigger?