Skip site navigation (1) Skip section navigation (2)

Varchar pkey instead of integer

From: "Robins Tharakan" <tharakan(at)gmail(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Varchar pkey instead of integer
Date: 2008-05-21 05:40:43
Message-ID: 36af4bed0805202240v5fbdd6bcv75643a6488cd1daf@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-performance
Hi,

I am currently designing a database and wanted to know something that may
sound trivial, but I thought its still good to confirm before dumping
millions of rows in it.

The design requires a few master tables with very limited rows, for e.g.
currency_denomination table could at the max have a few records like million
/ billion / crore (used in india) / lacs (india specific) and so on.

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 ?

p.s.: I am not as much concerned with the size that it'd take on the data
tables, as much as the fact that the select / insert performances shouldn't
suffer. However, if that increase in size (per data record) may make a
considerable impact on the performance, I would certainly want to take that
into account during design phase.

Any pointers / replies appreciated.

Regards,
*Robins Tharakan*

Responses

pgsql-performance by date

Next:From: Joshua D. DrakeDate: 2008-05-21 06:16:34
Subject: Re: Varchar pkey instead of integer
Previous:From: PFCDate: 2008-05-20 20:54:23
Subject: Re: improving performance for a delete

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group