Re: CHAR or VARCHAR

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Martin A(dot) Marques" <martin(at)math(dot)unl(dot)edu(dot)ar>
Cc: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: CHAR or VARCHAR
Date: 2001-03-22 15:05:37
Message-ID: 25819.985273537@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Martin A. Marques" <martin(at)math(dot)unl(dot)edu(dot)ar> writes:
> How does performace look when doing lots of searches on a VARCHAR
> column with respect of a CHAR column? That is my main concern.

There is *no* performance advantage of CHAR(n) over VARCHAR(n).
If anything, there is a performance lossage due to extra disk I/O
(because all those padding blanks take space, and time to read).

My advice is to use CHAR(n) when that semantically describes your data
(ie, truly fixed-width data, like US postal codes), or VARCHAR(n) when
that semantically describes your data (ie, variable-width with a hard
upper bound), or TEXT when that semantically describes your data (ie,
variable width with no specific upper bound). Worrying about
performance differences is a waste of time, because there aren't any.

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Bruno Wolff III 2001-03-22 15:19:36 Re: String REPLACE function
Previous Message Antti Linno 2001-03-22 14:50:33 Birthday search.