Re: varchar vs text columns

From: Andrew Sullivan <ajs(at)crankycanuck(dot)ca>
To: pgsql-admin(at)postgresql(dot)org
Subject: Re: varchar vs text columns
Date: 2007-07-23 19:11:15
Message-ID: 20070723191115.GI9196@phlogiston.dyndns.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Mon, Jul 23, 2007 at 11:33:54AM -0700, Jessica Richard wrote:
> What is the difference between varchar and text for a string column?
> What is the benefit of using each one?
> Is text better than varchar performance wise?

From the manual:

Tip: There are no performance differences between these
three types, apart from the increased storage size when using
the blank-padded type. While character(n) has performance
advantages in some other database systems, it has no such
advantages in PostgreSQL. In most situations text or
character varying should be used instead.

Note that varchar(n) will have a performance effect, because on
insert or update you have to check to make sure the input doesn't
exceed the specified length.

A

--
Andrew Sullivan | ajs(at)crankycanuck(dot)ca
I remember when computers were frustrating because they *did* exactly what
you told them to. That actually seems sort of quaint now.
--J.D. Baldwin

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Peter Eisentraut 2007-07-23 19:20:35 Re: varchar vs text columns
Previous Message Jessica Richard 2007-07-23 18:33:54 varchar vs text columns