Re: determining maxsize for character varying

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: okparanoid(at)free(dot)fr
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: determining maxsize for character varying
Date: 2007-06-16 15:07:08
Message-ID: 11149.1182006428@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

okparanoid(at)free(dot)fr writes:
> Hello i would like to know if not determining a max size value for a
> character varying's fields decrease the perfomance (perhaps size of
> stockage ?

No, more the other way around: specifying varchar(N) when you had to
pick N out of the air decreases performance, because of all the
essentially useless checks of the string length that Postgres has to
make. If you cannot defend a specific limit N as being required by your
application, then just make it unconstrained varchar (or better text).

Do *not* use char(N) for data with highly variable width; that one
definitely will cost you performance and disk space.

regards, tom lane

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message J6M 2007-06-18 08:39:15 Re: Database size
Previous Message Ragnar 2007-06-16 12:30:20 Re: determining maxsize for character varying