Re: Avoiding surrogate keys - Mailing list pgsql-general

From Grzegorz Jaśkiewicz
Subject Re: Avoiding surrogate keys
Date
Msg-id y2m2f4958ff1005040744o4a9b0deu58c0e23380a467fe@mail.gmail.com
Whole thread Raw
In response to Re: Avoiding surrogate keys  (Richard Broersma <richard.broersma@gmail.com>)
List 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.

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: pg9 beta1, make check fails
Next
From: Andy Colson
Date:
Subject: Re: pg9 beta1, make check fails