Re: underlying structure: varchar vs. text - Mailing list pgsql-general

From Mitch Vincent
Subject Re: underlying structure: varchar vs. text
Date
Msg-id 00b601c0d4e0$b6487aa0$1251000a@windows
Whole thread Raw
In response to underlying structure: varchar vs. text  (pnews@modulo.org)
Responses Re: Re: underlying structure: varchar vs. text
List 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 by date:

Previous
From: Joel Burton
Date:
Subject: Re: Newbie Question
Next
From: Stephan Szabo
Date:
Subject: Re: Re: a primer on trigger?