Re: using sequences

From: Erik Price <eprice(at)ptc(dot)com>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: using sequences
Date: 2003-06-17 19:00:13
Message-ID: 3EEF653D.3090808@ptc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bruno Wolff III wrote:

>>It seems you're right that I dont understand them. However, I don't
>>have any intent of calling it like this (without having generated a
>>value), rather, I was simply curious and playing around with the
>>commandline client, and following some instructions I had seen in
>>another post. I didn't realize that it needed to be "activated" for the
>>current session.
>
>
> "activated" isn't really the right word. When you call nextval you are
> giving a number that is unique. No one else gets to see that number
> (until you save it somewhere) which prevents contention between different
> connections trying to get unique numbers from the same sequence.
> currval is just a way to see the last value of nextval that was given to
> you. If one hasn't been given to you, then there isn't anything for
> currval to return.
>
> Related to this is that you should only use the uniqueness of sequence
> values. You shouldn't expect them to be continuous and you shouldn't
> expect them to be monotonicly increasing other than within a single
> session.

Thank you for that very clear explanation. I now understand both points
(esp about not depending on the values to be sequential outside of a
single session, which I hadn't considered before).

Regards,

Erik

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jason Earl 2003-06-17 19:01:35 Re: postgreSQL on NAS/SAN?
Previous Message Fontenot, Paul 2003-06-17 18:47:12 Re: How to Process Mail in Postgre?