Re: select/update performance?

From: Richard Huxton <dev(at)archonet(dot)com>
To: Bjørn T Johansen <btj(at)havleik(dot)no>, pgsql-general(at)postgresql(dot)org
Subject: Re: select/update performance?
Date: 2003-11-05 10:31:58
Message-ID: 200311051031.59199.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2003-11-05 10:33:09 Re: question
Previous Message Thierry Missimilly 2003-11-05 10:21:49 SET AUTOCOMMIT OFF