Re: Getting consecutive sequence values

Поиск
Список
Период
Сортировка
От Ed L.
Тема Re: Getting consecutive sequence values
Дата
Msg-id 200304041524.46342.pgsql@bluepolka.net
обсуждение исходный текст
Ответ на Re: Getting consecutive sequence values  (nolan@celery.tssi.com)
Список pgsql-general
On Friday April 4 2003 1:53, nolan@celery.tssi.com wrote:
> > select setval('id',nextval('id')+100)
>
> That's certainly tidier than my lengthy SQL statement, but I don't know
> that it solves the concurrent access issue.  What happens if a 2nd call
> to nextval is issued at the same time?

Have you considered creating a sequence object with a cache size of 100?

    CREATE SEQUENCE id CACHE 100;

This will cause the sequence number to be handed in groups of 100, whatever
the next available group of 100 is, and when that is exhausted, it'll do
what you'd expect.  So if session 1 grabs a value, it gets ids 1-100, and
then session 2 gets 101-200, and then if session 1 runs out and grabs
another, it automatically gets 201-300.

Ed


В списке pgsql-general по дате отправления:

Предыдущее
От: "Ed L."
Дата:
Сообщение: Re: dbmirror revisions
Следующее
От: nolan@celery.tssi.com
Дата:
Сообщение: Re: dbmirror revisions