From: Tom Lane <tgl@sss.pgh.pa.us>
To: Martin A. Marques <martin@math.unl.edu.ar>
Cc: Stephan Szabo <sszabo@megazone23.bigpanda.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: CHAR or VARCHAR
Date: Thu, 22 Mar 2001 10:05:37 -0500
Message-ID: <25819.985273537@sss.pgh.pa.us> (raw)
In-Reply-To: <01032208051900.07158@math.unl.edu.ar>
References: <Pine.BSF.4.21.0103211715080.37589-100000@megazone23.bigpanda.com>
<01032208051900.07158@math.unl.edu.ar>
"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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, martin@math.unl.edu.ar, sszabo@megazone23.bigpanda.com
Subject: Re: CHAR or VARCHAR
In-Reply-To: <25819.985273537@sss.pgh.pa.us>
References: <Pine.BSF.4.21.0103211715080.37589-100000@megazone23.bigpanda.com> <01032208051900.07158@math.unl.edu.ar> <25819.985273537@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox