Re: Re: underlying structure: varchar vs. text

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Mitch Vincent" <mitch(at)venux(dot)net>
Cc: pnews(at)modulo(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Re: Re: underlying structure: varchar vs. text
Date: 2001-05-04 23:28:57
Message-ID: 2728.989018937@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Mitch Vincent" <mitch(at)venux(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-05-05 00:11:41 Re: how to see rules
Previous Message newsreader 2001-05-04 23:22:03 Re: Daylight savings