Re: Avoiding surrogate keys

From: Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com>
To: Richard Broersma <richard(dot)broersma(at)gmail(dot)com>
Cc: Merlin Moncure <mmoncure(at)gmail(dot)com>, John R Pierce <pierce(at)hogranch(dot)com>, PGSQL Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Avoiding surrogate keys
Date: 2010-05-04 14:44:45
Message-ID: y2m2f4958ff1005040744o4a9b0deu58c0e23380a467fe@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

the rule of thumb for me is:
- if you have more than one column as PK - and are variable length,
or more than 2 columns, fixed length, no bigger than 8 bytes - go for
surrogate - always.
- if PK is variable length, on average longer than 8 bytes, or can
change - go surrogate.
- Otherwise leave it as it is.

At the end of a day, joining tables, using that have more than 1
variable length key, kills performance. In essence it makes index
search a PITA, and should be avoided.

This should always be however decision based on query performance,
usage, and data types. Never a textbook A or B type of thing.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andy Colson 2010-05-04 14:50:28 Re: pg9 beta1, make check fails
Previous Message Tom Lane 2010-05-04 14:37:43 Re: pg9 beta1, make check fails