pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedRe: unique sequences
2+ messages / 2 participants
[nested] [flat]
* Re: unique sequences
@ 2000-06-27 04:52 K Parker <kparker@eudoramail.com>
0 siblings, 1 reply; 2+ messages in thread
From: K Parker @ 2000-06-27 04:52 UTC (permalink / raw)
To: pgsql-sql@hub.org
> Rather, each time you wish to do an insert,
> query the existing data to see what the
> maximum value is existing in the database.
> Add 1 to that and use this as your new value.
> This is guaranteed to not have any holes in
> the sequence.
True, but alas it _doesn't_ guarantee uniqueness, since there's nothing to prohibit 2 or more back ends getting the same max() at the
same time...
Thinking off the top of my head, I'm not sure you can apply FOR UPDATE to an aggregate function, so there's probably no solution there, either.
Join 18 million Eudora users by signing up for a free Eudora Web-Mail account at http://www.eudoramail.com
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Re: unique sequences
@ 2000-06-27 11:12 DalTech - Continuing Technical Education <CTE@Dal.Ca>
parent: K Parker <kparker@eudoramail.com>
0 siblings, 0 replies; 2+ messages in thread
From: DalTech - Continuing Technical Education @ 2000-06-27 11:12 UTC (permalink / raw)
To: kparker@eudoramail.com; +Cc: pgsql-sql@hub.org
I imagine it should if you create a unique index on the field.
Cheers,
Christopher Currie
----- Original Message -----
From: K Parker <kparker@eudoramail.com>
To: <pgsql-sql@hub.org>
Sent: Tuesday, June 27, 2000 1:52 AM
Subject: [SQL] Re: unique sequences
> > Rather, each time you wish to do an insert,
> > query the existing data to see what the
> > maximum value is existing in the database.
> > Add 1 to that and use this as your new value.
> > This is guaranteed to not have any holes in
> > the sequence.
>
> True, but alas it _doesn't_ guarantee uniqueness, since there's nothing to
prohibit 2 or more back ends getting the same max() at the
> same time...
>
> Thinking off the top of my head, I'm not sure you can apply FOR UPDATE to
an aggregate function, so there's probably no solution there, either.
>
>
>
> Join 18 million Eudora users by signing up for a free Eudora Web-Mail
account at http://www.eudoramail.com
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2000-06-27 11:12 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-06-27 04:52 Re: unique sequences K Parker <kparker@eudoramail.com>
2000-06-27 11:12 ` DalTech - Continuing Technical Education <CTE@Dal.Ca>
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