Re: Postgresql indices (was Re: lisp mail archive software)
Zachary Beane <[email protected]> Mon, 7 Jul 2003 10:10:45 -0400
| Newsgroups | gmane.lisp.clump |
|---|---|
| Message-ID | <[email protected]> |
On Mon, Jul 07, 2003 at 10:08:18AM -0400, Zachary Beane wrote: > On Mon, Jul 07, 2003 at 02:53:10PM +0100, Daniel Barlow wrote: > > -----BEGIN PGP SIGNED MESSAGE----- > > Hash: SHA1 > > > > John DeSoi <[email protected]> writes: > > > > > I suspected this was the case. I'm doing something similar and opted > > > for a serial primary key for instances. It would be nice get an object > > > ID back from the insert without the need to call currval, but I > > > thought this was the best way to go since indexing is taken care of > > > with the primary key specification. > > > > Isn't that potentially racey? What happens if another user does an > > insert between when you do yours and when you call currval? > > This is a Postgres FAQ, and the answer is no. 'currval' is tracked per > session so you'll always get the result of your own most-recent > 'nextval', not someone else's. Also, FWIW, I typically select nextval first, then use that for the insert. In some situations it can help prevent UI glitches like a double-clicked "submit" button. Zach