Sequence Question

Поиск
Список
Период
Сортировка
От Oscar Tuscon
Тема Sequence Question
Дата
Msg-id 20040805041942.0D6513953@sitemail.everyone.net
обсуждение исходный текст
Ответы Re: Sequence Question  (Prabu Subroto <prabu_subroto@yahoo.com>)
Re: Sequence Question  (Greg Stark <gsstark@mit.edu>)
Список pgsql-general
I'm looking at ways to get batches of sequence values s faster. I don't want to set cache or increment to a large
numberfor a variety of reasons. I need to grab id's in batches of varying numbers at various times, from 1 to several
thousandat once. 
Doing it 1 at a time works, but more time goes into it than I'd like. I tried setting cache_value high but the database
roundtripswere eating more time that I wanted to see; I only saw a 25% improvement in average time. 

SO... is the following approach safe? That is, will this be atomic, or is there a possibility that another connection
couldsqueeze in a select nextval() between the select nextval() and the setval below? 
If it's safe I'd do this and take the sequences as the new currval - #I asked for (1500 or whatever).

mydb=# select setval('my_id_seq', (select nextval('my_id_seq')+1500));

Thanks
Oscar


_____________________________________________________________
The BMW E30 community on the web---> http://www.bmwe30.net

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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: Test case for bug fix in 7.4.3
Следующее
От: "Scott Marlowe"
Дата:
Сообщение: Re: Test case for bug fix in 7.4.3