Re: underlying structure: varchar vs. text

From: "Mitch Vincent" <mitch(at)venux(dot)net>
To: <pnews(at)modulo(dot)org>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: underlying structure: varchar vs. text
Date: 2001-05-04 21:25:15
Message-ID: 00b601c0d4e0$b6487aa0$1251000a@windows
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Steve Wolfe 2001-05-04 21:36:27 Re: IpcMemoryCreate: shmget failed (Invalid argument)
Previous Message Peter Eisentraut 2001-05-04 21:19:53 Re: Newbie Question