Re: Inefficient query plan - Mailing list pgsql-performance

From Kevin Grittner
Subject Re: Inefficient query plan
Date
Msg-id 4C72475F0200002500034A62@gw.wicourts.gov
Whole thread Raw
In response to Re: Inefficient query plan  (Grzegorz Jaśkiewicz <gryzman@gmail.com>)
List pgsql-performance
Grzegorz Jaœkiewicz<gryzman@gmail.com> wrote:

> So, don't narrow down to one solution because it worked for you.
> Keep an open book.

What I was trying to do was advise on what would most directly fix
the problem.  Adding surrogate keys goes way beyond adding the
columns and using them as keys, as I'm sure you're aware if you've
done this on a large scale.  I wouldn't tell someone not to ever use
them; I would advise not to try them when there is a natural key
unless there are problems which are not solved without them, as
appears to have been the case with your database.

I may be a little bit over-sensitive on the topic, because I've seen
so many people who consider it "wrong" to use natural keys on any
table *ever*.  About one out of every four or five programmers who
gets hired here feels compelled to argue that we should add
surrogate keys to all our tables for no reason beyond "it's the
thing to do".  I've been at this for 38 years, most of that as a
consultant to a wide variety of businesses, government agencies, and
NPOs; and in my experience it usually is *not* the right thing to
do.

Don't worry -- when I see evidence that surrogate keys will solve a
problem which has not yielded to more conservative solutions, I'll
suggest using them.

-Kevin

pgsql-performance by date:

Previous
From: Grzegorz Jaśkiewicz
Date:
Subject: Re: Inefficient query plan
Next
From: Tom Lane
Date:
Subject: Re: Inefficient query plan