Re: Generic design: char vs varchar primary keys

From: "Raj Mathur ( राज =?utf-8?b?IOCkruCkvuCkpeClgeCksA==?=)" <raju(at)linux-delhi(dot)org>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Generic design: char vs varchar primary keys
Date: 2011-08-04 01:58:25
Message-ID: 201108040728.26315.raju@linux-delhi.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thursday 04 Aug 2011, Josh Kupershmidt wrote:
> 2011/8/3 Raj Mathur (राज माथुर) <raju(at)linux-delhi(dot)org>:
> > Can you point me to any pages that explain the difference between
> > using, say CHAR(8) vs VARCHAR(8) as the primary key for a table?
> > Is there any impact on the database in terms of:
> >
> > - Speed of indexed retrieval
> > - Speed of join from a referencing table
> > - Storage (I presume VARHAR(8) would have a slight edge, in
> > general) - Any other issue
> I suspect the tiny size differences between char(8) and varchar(8)
> are going to be negligible. In fact, this post talks precisely about
> this concern, and more:
>
> http://www.depesz.com/index.php/2010/03/02/charx-vs-varcharx-vs-varc
> har-vs-text/
>
> Personally I'd be most worried about the different semantics of the
> types (i.e. treatment of trailing spaces), and perhaps the ease of
> expanding the length constraint in the future.

Thanks, that's useful for benchmarking the various textual data types.
Anything specific about using CHAR vs VARCHAR for primary keys that are
going to be referenced from multiple tables that comes to mind?

Regards,

-- Raj
--
Raj Mathur raju(at)kandalaya(dot)org http://kandalaya.org/
GPG: 78D4 FC67 367F 40E2 0DD5 0FEF C968 D0EF CC68 D17F
PsyTrance & Chill: http://schizoid.in/ || It is the mind that moves

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Gnanakumar 2011-08-04 07:54:39 Calculating relative time/distance from CURRENT_TIMESTAMP
Previous Message Josh Kupershmidt 2011-08-03 22:24:17 Re: Generic design: char vs varchar primary keys