Re: The best option to insert data with primary id

Поиск
Список
Период
Сортировка
От mike@if-then-else.pl
Тема Re: The best option to insert data with primary id
Дата
Msg-id 20101206172131.cjlul2oggc0848so@horde.iq.pl
обсуждение исходный текст
Ответ на The best option to insert data with primary id  (- <grandebuzon@gmail.com>)
Список pgsql-sql
Quoting - <grandebuzon@gmail.com>:

> I know you can skip SEQUENCE - ((SELECT nextval ('seq_table')) do not put
> this in the query, my question was that such concurrency, and ids
> omitted  which can not be inserted but increased with SEQUENCE ?

In the initial message you have been wondering, if you should be worried
about "wasted" sequence tokens.  You have mentioned, that your primary key
is of type int8 and so is the sequence range.  Do you really expect as many
records and/or insert queries?

If so, consider the id column int8 DEFAULT NULL and an AFTER INSERT trigger
function that would take a nextval of the sequence and update the id
accordingly once the record *has been actually inserted* instead of poking
the sequence each time you *are going to insert* something.

I am pretty sure, that the table is locked to prevent inserts until the
after-insert-trigger is finished.

Cheers,
   -Mike

--
Michał Roszka
mike@if-then-else.pl



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

Предыдущее
От: mike@if-then-else.pl
Дата:
Сообщение: Re: The best option to insert data with primary id
Следующее
От: bricklen
Дата:
Сообщение: Re: Union Question