Re: CHAR vs VARCHAR w/TOAST

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Brent R(dot) Matzelle" <bmatzelle(at)yahoo(dot)com>
Cc: PG General <pgsql-general(at)postgresql(dot)org>
Subject: Re: CHAR vs VARCHAR w/TOAST
Date: 2001-06-04 14:39:54
Message-ID: 29569.991665594@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Brent R. Matzelle" <bmatzelle(at)yahoo(dot)com> writes:
> Does this mean that scanning is just as fast using VARCHAR
> as CHAR? I was always taught to use CHAR on columns that I
> needed speedier search results. What are the facts?

See recent discussions on this point. There is no speed advantage to
CHAR() --- there never was more than a minuscule advantage to it in
Postgres, and that's now gone entirely. However, if you are taking
naturally variable-width data and forcing it into CHAR(n) via
blank-padding, then you are paying very real costs in disk space and
I/O time for all those extra blanks.

To me, the bottom line is: use the data type whose semantics fit your
data (for textual data, that could be char(n), varchar(n), or text,
depending on what you want to enforce about length limits). Anything
else is at best micro-optimization and more likely folly.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Lamar Owen 2001-06-04 14:51:04 Re: 7.1.2 packaging
Previous Message Tom Lane 2001-06-04 14:19:52 Re: PostgreSQL security concerns