Re: varchar(n) and text

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Yan Cheng Cheok <yccheok(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: varchar(n) and text
Date: 2010-02-04 01:31:11
Message-ID: 201002040131.o141VBA09478@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Yan Cheng Cheok wrote:
> According to http://www.postgresql.org/docs/8.0/interactive/datatype-character.html
>
> I always use TEXT, for column which store text so that I need not to worry on text length.
>
> However, in certain situation, I know that my text length will always < 10 characters
>
> I was wondering, if I using TEXT, will there have any overhead on
>
> (1) storage space?
> (2) query performance?
> (3) write performance?
>
> Shall I just use varchar(10) ?

This is an FAQ, and is mentioned in the manuals. The short answer is
that there is no different for any of them in any areas, except
documented behavior, e.g. char(10) is always output as 10 characters.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jorge Godoy 2010-02-04 01:56:40 Re: Shall I apply normalization in the following case?
Previous Message Yan Cheng Cheok 2010-02-04 01:27:33 varchar(n) and text