pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ross J. Reedstrom <reedstrm@rice.edu>
To: pgsql-interfaces@postgresql.org
Subject: Re: JDBC problem
Date: Fri, 25 Aug 2000 09:35:42 -0500
Message-ID: <20000825093542.A22705@rice.edu> (raw)
In-Reply-To: <Pine.LNX.4.21.0008251145460.14895-100000@nanu.visionforisrael.com>
References: <Pine.LNX.4.21.0008241808520.2783-100000@linux2.johnmckown.net>
	<Pine.LNX.4.21.0008251145460.14895-100000@nanu.visionforisrael.com>

On Fri, Aug 25, 2000 at 11:49:32AM +0300, Cedar Cox wrote:
> 
> 
> One detail that seems to have an advantage over the MAX+1 method is that
> in the case of adding a new record, deleting it, then adding another new
> record the ID will not be reused (correct?).  
> 
> Question:  What happens when transactions enter the picture?  Will you get
> duplicate values, or holes, or does it work just fine?

Well, in my opinion it works just fine, but that does mean you get holes.
This has been discussed do death over on GENERAL a number of times. In
order to avoid locking on the serial seequence generator, multiple
transacations each get to increment the counter, but do not roll it
back on transaction failure. And each connection maintains it's own
state of the underlying sequence, so that currval('table_field_seq')
is multiuser safe.

And as you mention above, not reusing numbers also leads to holes, so
your app needs to be able to handle that, anyway.

Ross
-- 
Ross J. Reedstrom, Ph.D., <reedstrm@rice.edu> 
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St.,  Houston, TX 77005



view thread (17+ messages)  latest in thread

Message-ID: <20000825093542.A22705@rice.edu>
Permalink:  ../20000825093542.A22705@rice.edu/
Also on:    postgresql.org/message-id/20000825093542.A22705@rice.edu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: reedstrm@rice.edu
  Subject: Re: JDBC problem
  In-Reply-To: <20000825093542.A22705@rice.edu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox