pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Merlin Moncure <mmoncure@gmail.com>
To: Craig A. James <cjames@modgraph-usa.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Basic Q on superfluous primary keys
Date: Mon, 16 Apr 2007 11:55:29 -0400
Message-ID: <b42b73150704160855s676a8c43n7ef4282f5ef175c9@mail.gmail.com> (raw)
In-Reply-To: <46239000.7000708@modgraph-usa.com>
References: <c2350ba40704140419r2f3c85dfi60171759b71f4db7@mail.gmail.com>
	<20070414075947.e5fbeec8.wmoran@collaborativefusion.com>
	<b42b73150704160603x1d164134pfd2af7481f802ed9@mail.gmail.com>
	<46239000.7000708@modgraph-usa.com>

On 4/16/07, Craig A. James <cjames@modgraph-usa.com> wrote:
> Merlin Moncure wrote:
> > Using surrogate keys is dangerous and can lead to very bad design
> > habits that are unfortunately so prevalent in the software industry
> > they are virtually taught in schools.  ...  While there is
> > nothing wrong with them in principle (you are exchanging one key for
> > another as a performance optimization), they make it all too easy to
> > create denormalized designs and tables with no real identifying
> > criteria, etc,...

> I can't recall ever seeing a "natural" key that was immutable.  In my business (chemistry), we've seen several disasterous situations were companies picked keys they thought were natural and immutable, and years down the road they discovered (for example) that chemical compounds they thought were pure were in fact isotopic mixtures, or simply the wrong molecule (as analytical techniques improved).  Or during a corporate takeover, they discovered that two companies using the same "natural" keys had as much as 10% differences in their multi-million-compound databases.  These errors led to six-month to year-long delays, as each of the conflicting chemical record had to be examined by hand by a PhD chemist to reclassify it.

while your example might be a good case study in proper
classification, it has nothing to do with key selection.  it is
especially unclear how adding an integer to a table will somehow
magically solve these problems.  are you claiming that a primary key
can't be changed?

mutability is strictly a performance argument.  since RI handles
cascading primary key changes, it's simply a matter of if you are
willing to wait for RI to do its work or not (if not, swap in the id
key as in my example).  the performance argument really only applies
to specific cases, and can be considered a attribute of certain
tables.  extraordinary cases do happen, like a company overhauling its
numbering systems, but such cases can be dealt with by a number of
methods including letting RI do its thing.

merlin



view thread (17+ messages)  latest in thread

Message-ID: <b42b73150704160855s676a8c43n7ef4282f5ef175c9@mail.gmail.com>
Permalink:  ../b42b73150704160855s676a8c43n7ef4282f5ef175c9@mail.gmail.com/
Also on:    postgresql.org/message-id/b42b73150704160855s676a8c43n7ef4282f5ef175c9@mail.gmail.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: mmoncure@gmail.com, cjames@modgraph-usa.com
  Subject: Re: Basic Q on superfluous primary keys
  In-Reply-To: <b42b73150704160855s676a8c43n7ef4282f5ef175c9@mail.gmail.com>
  References: <c2350ba40704140419r2f3c85dfi60171759b71f4db7@mail.gmail.com> <20070414075947.e5fbeec8.wmoran@collaborativefusion.com> <b42b73150704160603x1d164134pfd2af7481f802ed9@mail.gmail.com> <46239000.7000708@modgraph-usa.com> <b42b73150704160855s676a8c43n7ef4282f5ef175c9@mail.gmail.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