pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joshua D. Drake <jd@commandprompt.com>
To: Robins Tharakan <tharakan@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Varchar pkey instead of integer
Date: Tue, 20 May 2008 23:16:34 -0700
Message-ID: <4833BE42.5030409@commandprompt.com> (raw)
In-Reply-To: <36af4bed0805202240v5fbdd6bcv75643a6488cd1daf@mail.gmail.com>
References: <36af4bed0805202240v5fbdd6bcv75643a6488cd1daf@mail.gmail.com>

Robins Tharakan wrote:
> Hi,

> Now what I wanted to ask was whether its any different to have the 
> primary-keys in such master tables as text/varchar rather than integer ? 
> i.e. Can I use a character varying(10) and use the text 'million' / 
> 'billion' instead of a serial / integer type ?

One should ask themselves why before can I. :)

If you want to use a varchar() for a primary key that is fine but make 
it a natural key not an arbitrary number. If you are going to use 
arbitrary numbers, use a serial or bigserial.

Joshua D. Drake




view thread (7+ messages)  latest in thread

Message-ID: <4833BE42.5030409@commandprompt.com>
Permalink:  ../4833BE42.5030409@commandprompt.com/
Also on:    postgresql.org/message-id/4833BE42.5030409@commandprompt.com

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: jd@commandprompt.com, tharakan@gmail.com
  Subject: Re: Varchar pkey instead of integer
  In-Reply-To: <4833BE42.5030409@commandprompt.com>

* 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