Re: Multiple multithreaded insert

Поиск
Список
Период
Сортировка
От Scott Marlowe
Тема Re: Multiple multithreaded insert
Дата
Msg-id CAOR=d=1kxAz5EaE_7_-v-7vibAh+mfcx79xA7Jws9bAW+PV7rw@mail.gmail.com
обсуждение исходный текст
Ответ на Multiple multithreaded insert  (Арсен Арутюнян <arutar@bk.ru>)
Список pgsql-general
On Fri, Oct 14, 2016 at 7:12 AM, Арсен Арутюнян <arutar@bk.ru> wrote:
> Hi, everyone!
>
> I have a table:
>
> create table testpr(id serial,priority integer,unique(priority) DEFERRABLE,
> primary key(id));
>

This:

> and a trigger which, when added to this table, automatically sets priority
> as the maximum value +1

Leads to THIS:

> The result (priority):
>
> Thread 1: (1) (2) (3) (4) (5) (6) (7)
>
> Thread 2: (8) (9) (10) (11) (12) (13) (14)

If you have to have monotonically increasing priorities with no gaps,
that's the price you pay, unless you can pre-allocate them or
something.

Basically max(id)+1 is a db anti-pattern.


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

Предыдущее
От: Арсен Арутюнян
Дата:
Сообщение: Multiple multithreaded insert
Следующее
От: "FarjadFarid\(ChkNet\)"
Дата:
Сообщение: Re: Multiple multithreaded insert