Re: Change the behaviour of the SERIAL "Type"

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: Change the behaviour of the SERIAL "Type"
Дата
Msg-id 20030627152031.GF15269@wolff.to
обсуждение исходный текст
Ответ на Re: Change the behaviour of the SERIAL "Type"  (Dani Oderbolz <oderbolz@ecologic.de>)
Список pgsql-sql
On Fri, Jun 27, 2003 at 16:35:36 +0200, Dani Oderbolz <oderbolz@ecologic.de> wrote:
> Well, why not just use the Sequence?
> Is there really such a performance hit when calling a trigger?

I think the big issue is concurrency. Sequences are designed so that
conncurrent uses of the sequence don't block each other. In the trigger
based methods you have to lock the value against concurrent update and
this lock will be held to the end of the transaction. This has the
potential to really hurt your performance.

I may have been misunderstanding what you are trying to do though.
If your problem was that people could update or insert values into
the serial column that might cause other transactions to unexpected
fail (when they try to use a duplicate value - assuming you use a unique
index on the column) then you could use a trigger to prevent updates
on that column and force inserts to always use nextval. If you need
to reload the database at some point, you will need to do something
to keep the triggers from interfering with the reload. This should
be fairly efficient.

I had thought you were concerned about possible gaps in the sequence.


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

Предыдущее
От: Bruno Wolff III
Дата:
Сообщение: Re: Getting all rows even if not a member of any groups
Следующее
От:
Дата:
Сообщение: Re: Postgres - Delphi Application