Re: CHAR or VARCHAR - Mailing list pgsql-sql

From Tom Lane
Subject Re: CHAR or VARCHAR
Date
Msg-id 25819.985273537@sss.pgh.pa.us
Whole thread Raw
In response to Re: CHAR or VARCHAR  ("Martin A. Marques" <martin@math.unl.edu.ar>)
Responses Re: CHAR or VARCHAR  ("Peter J. Schoenster" <peter@schoenster.com>)
List pgsql-sql
"Martin A. Marques" <martin@math.unl.edu.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


pgsql-sql by date:

Previous
From: "Richard Huxton"
Date:
Subject: Re: how to build this string ?
Next
From: Christof Glaser
Date:
Subject: Re: Foreign key referencing subclasses.