On Fri, Oct 14, 2016 at 7:12 AM, Арсен Арутюнян <aru...@bk.ru> wrote:
> Hi, everyone!
> I have a table:
> create table testpr(id serial,priority integer,unique(priority) DEFERRABLE,
> primary key(id));
> 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
Basically max(id)+1 is a db anti-pattern.
Sent via pgsql-general mailing list (email@example.com)
To make changes to your subscription: