pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tim Cross <theophilusx@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Table partitioning with sequence field in postgresql12
Date: Thu, 18 Jun 2020 17:09:25 +1000
Message-ID: <87tuz8zw7u.fsf@gmail.com> (raw)
In-Reply-To: <CAFruNdfXBjr535LRd3X2GSD8XxF7Tvq7q7MG+mOVKKN3sFNHoA@mail.gmail.com>
References: <CAFruNdfSD_i12pQWNwOY-ixM4DgWEzOHR_oHhQ5EbUmm3apUFA@mail.gmail.com>
	<CAAJ_b95oB5fiQR15N9c+nzOHYbniYa2_iJh8dT57dN47x40r0Q@mail.gmail.com>
	<CAFruNdfXBjr535LRd3X2GSD8XxF7Tvq7q7MG+mOVKKN3sFNHoA@mail.gmail.com>


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





view thread (7+ messages)

Message-ID: <87tuz8zw7u.fsf@gmail.com>
Permalink:  ../87tuz8zw7u.fsf@gmail.com/
Also on:    postgresql.org/message-id/87tuz8zw7u.fsf@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: theophilusx@gmail.com
  Subject: Re: Table partitioning with sequence field in postgresql12
  In-Reply-To: <87tuz8zw7u.fsf@gmail.com>
  References: <CAFruNdfSD_i12pQWNwOY-ixM4DgWEzOHR_oHhQ5EbUmm3apUFA@mail.gmail.com> <CAAJ_b95oB5fiQR15N9c+nzOHYbniYa2_iJh8dT57dN47x40r0Q@mail.gmail.com> <CAFruNdfXBjr535LRd3X2GSD8XxF7Tvq7q7MG+mOVKKN3sFNHoA@mail.gmail.com> <87tuz8zw7u.fsf@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox