Re: Difference between varchar and text?

From: Abel Abraham Camarillo Ojeda <acamari(at)the00z(dot)org>
To:
Cc: David Johnston <polobo(at)yahoo(dot)com>, John R Pierce <pierce(at)hogranch(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Difference between varchar and text?
Date: 2012-11-18 07:48:39
Message-ID: CAPD=2Nj=1uvC0bnK7TWFVym-U3n4n--X6Jamv9o6t4Kp4Jt1wA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, Nov 18, 2012 at 1:29 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> David Johnston <polobo(at)yahoo(dot)com> writes:
>> On Nov 17, 2012, at 20:43, John R Pierce <pierce(at)hogranch(dot)com> wrote:
>>> I think he meant a tiny tiny bit faster, primarily due to not having to validate the length.
>
>> Maybe... But I would presume a "varchar with no limit" does not validate length...
>
> There is overhead from the type system for varchar, whether or not it
> has a length limit --- you'll get at least some RelabelType nodes in
> expression trees, and those don't have zero cost to execute.
>
> I'd generally recommend using "text" if you don't have any interest in
> enforcing a specific length limit.
>
> regards, tom lane
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general

As far as I know varchar(n) with n being less or equal than 126 cannot be
toasted, and have only one octet of overhead.

http://www.postgresql.org/docs/9.2/static/storage-toast.html

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2012-11-18 08:39:47 Re: Difference between varchar and text?
Previous Message Tom Lane 2012-11-18 07:33:02 Re: Prepared Statement Name Truncation