Re: The speed problem of Varchar vs. Char

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Crystal <support(at)conceptpatterns(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: The speed problem of Varchar vs. Char
Date: 2007-07-08 23:59:02
Message-ID: 18910.1183939142@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Crystal <support(at)conceptpatterns(dot)com> writes:
> Our company need to save contact details into the PostgreSQL database. I
> just begin to learn it, so I got many questions. I am not sure which
> data type I should choose for website address, varchar or char.

Use varchar. Or text, if you don't have a specific upper limit in mind.

> The website address may be very long, and we also don't want to lose the
> speed. Thus, the question is: if we have a large contact database, how
> much slowdown or speed up will be expected if we choose variable length
> rather than fixed length? Thanks forward.

Once upon a time, in the days of 80-column punch cards and no
variable-length character encodings, there were databases that could
handle fixed-width character fields a bit faster than variable-width.
That doesn't apply to Postgres. There is no, none, nada performance
advantage to char(n), and you should never use it unless your
application data clearly demands a specific field width.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Crystal 2007-07-09 00:00:11 Re: The speed problem of Varchar vs. Char
Previous Message Josh Tolley 2007-07-08 23:56:41 Re: The speed problem of Varchar vs. Char