From: | Tim Cross <theophilusx(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: Table partitioning with sequence field in postgresql12 |
Date: | 2020-06-18 07:09:25 |
Message-ID: | 87tuz8zw7u.fsf@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Srinivasa T N <seenutn(at)gmail(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Matthias Apitz | 2020-06-18 07:13:55 | Re: ESQL/C no indicator variables ./. error -213 |
Previous Message | Toomas Kristin | 2020-06-18 07:09:00 | Re: Conflict with recovery on PG version 11.6 |