Re: arbitrary number of values from a sequence

From: "Gyozo Papp" <pgerzson(at)freestart(dot)hu>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: arbitrary number of values from a sequence
Date: 2001-05-05 12:33:22
Message-ID: 005d01c0d55f$932d41c0$4647c5d5@jaguar
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ok. I'm looking for another solution.

The reason why I'm not dealing with sequence's increment is that
there is no way to set an appropiate limit, sometimes I need 5, sometimes 17.

Thanks for your help,

Papp Gyozo
- pgerzson(at)freestart(dot)hu

----- Original Message -----
From: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Gyozo Papp" <pgerzson(at)freestart(dot)hu>
Cc: <pgsql-general(at)postgresql(dot)org>
Sent: 2001. május 4. 20:26
Subject: Re: [GENERAL] arbitrary number of values from a sequence

> "Gyozo Papp" <pgerzson(at)freestart(dot)hu> writes:
> > Does it mean that it can't be ensured that returning values of
> > nextval() are consecutive ones?
>
> I think it would be folly to assume that, even with a cache setting
> equal to the number of values you intend to fetch. If the cache gets
> out of sync with your requests (say, because a transaction aborted after
> fetching just some of the 5 values) then subsequent transactions would
> reload the cache partway through, and in that case you could get
> non-consecutive results.
>
> > does it help me if I set the transaction isolation level to
> > serializable or lock the table of the sequence?
>
> No. Why do you need such a thing, anyway? If you are always allocating
> groups of 5 IDs, why don't you just pretend each nextval() gives you
> five items instead of one? You could simply multiply the returned value
> by 5. Or set the sequence's increment to 5.
>
> regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Eric G. Miller 2001-05-05 13:13:06 Re: arbitrary number of values from a sequence
Previous Message Jesus Aneiros 2001-05-05 12:28:36 Re: psql with PHP question