Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

varchar vs text columns

0 views
Skip to first unread message

Jessica Richard

unread,
Jul 23, 2007, 2:33:54 PM7/23/07
to
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?

Thanks.


Park yourself in front of a world of choices in alternative vehicles.
Visit the Yahoo! Auto Green Center.

Andrew Sullivan

unread,
Jul 23, 2007, 3:11:15 PM7/23/07
to
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 | a...@crankycanuck.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

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Peter Eisentraut

unread,
Jul 23, 2007, 3:20:35 PM7/23/07
to
Jessica Richard wrote:
> What is the difference between varchar and text for a string column?

Nothing, if you don't use a limit for varchar.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majo...@postgresql.org so that your
message can get through to the mailing list cleanly

Lew

unread,
Jul 24, 2007, 9:16:49 AM7/24/07
to
Andrew Sullivan wrote:
> 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.

See also Peter Koczan's reply in the '"_" in a serach pattern' thread.

--
Lew

0 new messages