Re: How to don't update sequence on rollback of a transaction

Поиск
Список
Период
Сортировка
От Chris Angelico
Тема Re: How to don't update sequence on rollback of a transaction
Дата
Msg-id CAPTjJmrc=0CQWU7L2Z1L+pYrOOQp=HxCCvNmA4EQAaSOh=BqMw@mail.gmail.com
обсуждение исходный текст
Ответ на How to don't update sequence on rollback of a transaction  (Frank Lanitz <frank@frank.uvena.de>)
Список pgsql-general
On Fri, Aug 3, 2012 at 1:08 AM, Frank Lanitz <frank@frank.uvena.de> wrote:
> My understanding of all was that it includes sequences. Obviously, I'm
> wrong... but how to do it right?

Sequences are fast and lock-free, but don't guarantee absence of gaps.
Quite a few things can unexpectedly advance a sequence (including
master-slave failover in replication - I've noticed IDs jump by about
32).

What should happen when two transactions simultaneously want a new ID?
Should the second block, waiting for the first one to commit or roll
back? Or will you allow the gaps, just as long as they get filled in
later?

The easiest way is probably to have a dedicated table of available
numbers, and use DELETE ... RETURNING to get the next one.

ChrisA

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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: "seeking help to collect some postgres meta data"
Следующее
От: Ingmar Brouns
Дата:
Сообщение: The semantics of (NULL,NULL) vs NULL