pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Table partitioning with sequence field in postgresql12
7+ messages / 3 participants
[nested] [flat]

* Table partitioning with sequence field in postgresql12
@ 2020-06-18 06:30  Srinivasa T N <seenutn@gmail.com>
  0 siblings, 2 replies; 7+ messages in thread

From: Srinivasa T N @ 2020-06-18 06:30 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

Hi,
   Partitioning of a table with sequence id as one of its fields is
supported in postgresql12?

Regards,
Seenu.

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Table partitioning with sequence field in postgresql12
@ 2020-06-18 06:39  amul sul <sulamul@gmail.com>
  parent: Srinivasa T N <seenutn@gmail.com>
  1 sibling, 1 reply; 7+ messages in thread

From: amul sul @ 2020-06-18 06:39 UTC (permalink / raw)
  To: Srinivasa T N <seenutn@gmail.com>; +Cc: pgsql-general@lists.postgresql.org

On Thu, Jun 18, 2020 at 12:00 PM Srinivasa T N <seenutn@gmail.com> wrote:
>
> Hi,
>    Partitioning of a table with sequence id as one of its fields is supported in postgresql12?
>
Could you please elaborate on your case a bit more?

Regards,
Amul





^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Table partitioning with sequence field in postgresql12
@ 2020-06-18 06:52  Srinivasa T N <seenutn@gmail.com>
  parent: amul sul <sulamul@gmail.com>
  0 siblings, 2 replies; 7+ messages in thread

From: Srinivasa T N @ 2020-06-18 06:52 UTC (permalink / raw)
  To: amul sul <sulamul@gmail.com>; +Cc: pgsql-general@lists.postgresql.org

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?

Regards,
Seenu.


On Thu, Jun 18, 2020 at 12:09 PM amul sul <sulamul@gmail.com> wrote:

> On Thu, Jun 18, 2020 at 12:00 PM Srinivasa T N <seenutn@gmail.com> wrote:
> >
> > Hi,
> >    Partitioning of a table with sequence id as one of its fields is
> supported in postgresql12?
> >
> Could you please elaborate on your case a bit more?
>
> Regards,
> Amul
>

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Table partitioning with sequence field in postgresql12
@ 2020-06-18 06:57  Tim Cross <theophilusx@gmail.com>
  parent: Srinivasa T N <seenutn@gmail.com>
  1 sibling, 0 replies; 7+ messages in thread

From: Tim Cross @ 2020-06-18 06:57 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org


Srinivasa T N <seenutn@gmail.com> writes:

> Hi,
>    Partitioning of a table with sequence id as one of its fields is
> supported in postgresql12?
>
> Regards,
> Seenu.

A sequence is really just an 'atomic' number generator, you get the next
value, which is guaranteed to be larger than the last 'nextval' (up
until maxvalue). It is unaware of the use i.e. whether it will be used
in a insert or what table that insert is against. So I'm not sure what
your concern with a partitioned table is? Can you elaborate?

-- 
Tim Cross





^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Table partitioning with sequence field in postgresql12
@ 2020-06-18 07:00  amul sul <sulamul@gmail.com>
  parent: Srinivasa T N <seenutn@gmail.com>
  1 sibling, 1 reply; 7+ messages in thread

From: amul sul @ 2020-06-18 07:00 UTC (permalink / raw)
  To: Srinivasa T N <seenutn@gmail.com>; +Cc: pgsql-general@lists.postgresql.org

On Thu, Jun 18, 2020 at 12:22 PM Srinivasa T N <seenutn@gmail.com> wrote:
>
> 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?
>
if "gid" is the partitioning key and assuming you are using declarative
partitioning[1], then it won't be possible to have the same "gid" value in two
child partitions.

1] https://www.postgresql.org/docs/current/ddl-partitioning.html

regards,
Amul





^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Table partitioning with sequence field in postgresql12
@ 2020-06-18 07:03  Srinivasa T N <seenutn@gmail.com>
  parent: amul sul <sulamul@gmail.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Srinivasa T N @ 2020-06-18 07:03 UTC (permalink / raw)
  To: amul sul <sulamul@gmail.com>; +Cc: pgsql-general@lists.postgresql.org

I am using declarative partitioning on some other field of the same table
in which gid also exists.

Regards,
Seenu.


On Thu, Jun 18, 2020 at 12:31 PM amul sul <sulamul@gmail.com> wrote:

> On Thu, Jun 18, 2020 at 12:22 PM Srinivasa T N <seenutn@gmail.com> wrote:
> >
> > 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?
> >
> if "gid" is the partitioning key and assuming you are using declarative
> partitioning[1], then it won't be possible to have the same "gid" value in
> two
> child partitions.
>
> 1] https://www.postgresql.org/docs/current/ddl-partitioning.html
>
> regards,
> Amul
>

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Table partitioning with sequence field in postgresql12
@ 2020-06-18 07:09  Tim Cross <theophilusx@gmail.com>
  parent: Srinivasa T N <seenutn@gmail.com>
  1 sibling, 0 replies; 7+ messages in thread

From: Tim Cross @ 2020-06-18 07:09 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org


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





^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2020-06-18 07:09 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-06-18 06:30 Table partitioning with sequence field in postgresql12 Srinivasa T N <seenutn@gmail.com>
2020-06-18 06:39 ` amul sul <sulamul@gmail.com>
2020-06-18 06:52   ` Srinivasa T N <seenutn@gmail.com>
2020-06-18 07:00     ` amul sul <sulamul@gmail.com>
2020-06-18 07:03       ` Srinivasa T N <seenutn@gmail.com>
2020-06-18 07:09     ` Tim Cross <theophilusx@gmail.com>
2020-06-18 06:57 ` Tim Cross <theophilusx@gmail.com>

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