Re: select/update performance? - Mailing list pgsql-general

From Richard Huxton
Subject Re: select/update performance?
Date
Msg-id 200311051031.59199.dev@archonet.com
Whole thread Raw
In response to Re: select/update performance?  (Bjørn T Johansen <btj@havleik.no>)
List pgsql-general
On Wednesday 05 November 2003 09:49, Bjørn T Johansen wrote:
> Yes, but the table in question have 3 PK and only one that needs this
> "sequence" so I just thought instead of getting holes in the IDs I just
> manually handle this counter somehow.. Not a big deal but... :)

Do you mean a 3-column primary key? By definition you can't have more than one
primary key.

If you absolutely need to have no holes in your sequence numbers (e.g. for
invoices) then you will have to handle it yourself. If you can live with
them, it is much easier and quicker to use a sequence.

If you don't want holes, the simplest way is probably to have a "next_id"
column in a system-settings table. You'll need to lock it before
reading/updating and this will be a bottleneck when inserting new rows.
--
  Richard Huxton
  Archonet Ltd

pgsql-general by date:

Previous
From: Thierry Missimilly
Date:
Subject: SET AUTOCOMMIT OFF
Next
From: Richard Huxton
Date:
Subject: Re: question