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

From Tom Lane
Subject Re: Re: underlying structure: varchar vs. text
Date
Msg-id 2728.989018937@sss.pgh.pa.us
Whole thread Raw
In response to Re: underlying structure: varchar vs. text  ("Mitch Vincent" <mitch@venux.net>)
List pgsql-general
"Mitch Vincent" <mitch@venux.net> writes:
>> 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.

In 7.1 there's no real limit.  (I think the parser arbitrarily insists
that the N in varchar(N) be no more than 10 million, just on the theory
that it's probably a typo if you wrote more.  That's easily changed if
you really have a use for "varchar(100000000)" as opposed to just plain
"text" ... but offhand I can't see what it would be.  Text is the
appropriate type to use if you don't have a specific width limit in
mind.)

As far as efficiency goes, the only difference between text and
varchar() is the extra function call involved in applying varchar's
length limit check just before inserting or updating a row.  Physical
storage is the same.

The 2100 number refers to the maximum length of text that can be
indexed.  That hasn't moved much in 7.1, but I can't really see the
value of a direct index on megabyte-sized text values anyway...

            regards, tom lane

pgsql-general by date:

Previous
From: Martín Marqués
Date:
Subject: how to see rules
Next
From: Tom Lane
Date:
Subject: Re: Daylight savings