Re: Table partitioning with sequence field in postgresql12 - Mailing list pgsql-general

From Tim Cross
Subject Re: Table partitioning with sequence field in postgresql12
Date
Msg-id 87tuz8zw7u.fsf@gmail.com
Whole thread Raw
In response to Re: Table partitioning with sequence field in postgresql12  (Srinivasa T N <seenutn@gmail.com>)
List pgsql-general
Srinivasa T N <seenutn@gmail.com> writes:

> Hi,
>    I have a parent table with one of the field as ""gid" int4 DEFAULT
> nextval('"ami_smart_new".aoi_boundary_gid_seq'::regclass)".
>
>    I create child tables which inherit parent and use hash partition.  When
> I directly insert into child tables, will there be any race condition
> causing two child tables getting the same sequence value for gid?
>
Assuming all inserts use the default e.g. nextval from the same
sequence, you won't get duplicates. You could get a duplicate if an
insert sets an explicit value for gid of course or if rows in any table
were inserted with a gid which was not obtained from the same sequence
using nextval i.e. parent and children use same sequence. The sequence
is just a counter with the property that no two calls to nextval from
that sequence will have the same value. You cannot make any additional
assumptions e.g. cannot assume gid values will be inserted in order or
there won't be 'gaps ' etc.
-- 
Tim Cross



pgsql-general by date:

Previous
From: Toomas Kristin
Date:
Subject: Re: Conflict with recovery on PG version 11.6
Next
From: Matthias Apitz
Date:
Subject: Re: ESQL/C no indicator variables ./. error -213