Re: sequence's plpgsql

Поиск
Список
Период
Сортировка
Искать
От
Richard Huxton
Тема
Re: sequence's plpgsql
Дата
Msg-id
200309241828.06757.dev@archonet.com
Ответ на
sequence's plpgsql (Tim McAuley)
Список
Дерево обсуждения
sequence's plpgsql Tim McAuley <mcauleyt@tcd.ie>
Re: sequence's plpgsql Richard Huxton <dev@archonet.com>
Re: sequence's plpgsql Tim McAuley <mcauleyt@tcd.ie>
Re: sequence's plpgsql Tom Lane <tgl@sss.pgh.pa.us>
Re: sequence's plpgsql Tim McAuley <mcauleyt@tcd.ie>
On Wednesday 24 September 2003 17:40, Tim McAuley wrote:
> Hi,
>
> I've hit a little problem and was wondering if anyone might be able to
> give some help.
>
> Set-up:
>
> - JBoss appserver using entity beans to access database
> - Using sequence pattern to update primary keys for several tables.
> Basically it is a method of getting primary keys without hitting the
> database. It actually hits the database every 10th go and updates the
> counter by 10 in the database.

You might want to try just using sequences - PG does some caching of generated 
values for you. Sorry - can't remember how you alter the cache size, but try
  SELECT * FROM my_sequence;
to see the details of its settings.

Use sequences, and from your sequence-holding class do something like:
  SELECT nextval('myseq'),nextval('myseq'),...10 times...
That will give you a block of 10 sequence values in one go, and off you go.

If you'd rather have the values in one column, create a single-column table 
"seq_count" and populate with values 1..10 then:
SELECT nextval('myseq'),seq_count.id FROM seq_count;

That any use?
-- 
  Richard Huxton
  Archonet Ltd
В списке pgsql-general по дате отправления
От: Bruce Momjian
Дата:
От: Jan Wieck
Дата:
FAQ