Re: [Solved] SQL Server to PostgreSQL - Mailing list pgsql-general

From Tom Lane
Subject Re: [Solved] SQL Server to PostgreSQL
Date
Msg-id 23740.967000276@sss.pgh.pa.us
Whole thread Raw
In response to Re: [Solved] SQL Server to PostgreSQL  ("Jeffrey A. Rhines" <jrhines@email.com>)
Responses Re: [Solved] SQL Server to PostgreSQL  (Radoslaw Stachowiak <radek@alter.pl>)
List pgsql-general
"Jeffrey A. Rhines" <jrhines@email.com> writes:
>> Uh ... what's wrong with varchar(n) ?
>
> I've wondered that myself, actually.  What are the benefits and
> drawbacks to going with one over the other, besides the obvious 255-char
> field length limit for varchar?

AFAIK there has *never* been a 255-char limit on char or varchar in
pgsql ... you must be thinking of Some Other DBMS.

The limit for these datatypes in 7.0 and before is BLCKSZ less some
overhead --- ~8000 bytes in a default setup.  Beginning in 7.1 it's
an essentially arbitrary number.  I set it at 10Mb in current sources,
but there's no strong reason for that number over any other.  In theory
it could be up to 1Gb, but as Jan Wieck points out in a nearby thread,
you probably wouldn't like the performance of shoving gigabyte-sized
text values around.  We need to think about offering API functions that
will allow reading and writing huge field values in bite-sized chunks.

There's no essential performance difference between char(n), varchar(n),
and text in Postgres, given the same-sized data value.  char(n)
truncates or blank-pads to exactly n characters; varchar(n) truncates
if more than n characters; text never truncates nor pads.  Beyond that
they are completely identical in storage requirements.  Pick one based
on the semantics you want for your application.

            regards, tom lane

pgsql-general by date:

Previous
From: brianb-pggeneral@edsamail.com
Date:
Subject: Re: Server Overload
Next
From: Franck Martin
Date:
Subject: RE: [Solved] SQL Server to PostgreSQL