Re: The speed problem of Varchar vs. Char - Mailing list pgsql-general

From Tom Lane
Subject Re: The speed problem of Varchar vs. Char
Date
Msg-id 18910.1183939142@sss.pgh.pa.us
Whole thread Raw
In response to The speed problem of Varchar vs. Char  (Crystal <support@conceptpatterns.com>)
Responses Re: The speed problem of Varchar vs. Char
List pgsql-general
Crystal <support@conceptpatterns.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

pgsql-general by date:

Previous
From: "Josh Tolley"
Date:
Subject: Re: The speed problem of Varchar vs. Char
Next
From: Crystal
Date:
Subject: Re: The speed problem of Varchar vs. Char