Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
Cc: Dmitry Koval <d(dot)koval(at)postgrespro(dot)ru>, Alexander Lakhin <exclusion(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Add SPLIT PARTITION/MERGE PARTITIONS commands
Date: 2024-04-28 13:18:42
Message-ID: Zi5Msg74C61DjJKW@pryzbyj2023
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Apr 28, 2024 at 04:04:54AM +0300, Alexander Korotkov wrote:
> Hi Justin,
>
> Thank you for your review. Please check v9 of the patchset [1].
>
> On Wed, Apr 24, 2024 at 11:26 PM Justin Pryzby <pryzby(at)telsasoft(dot)com> wrote:
> > This patch also/already fixes the schema issue I reported. Thanks.
> >
> > If you wanted to include a test case for that:
> >
> > begin;
> > CREATE SCHEMA s;
> > CREATE SCHEMA t;
> > CREATE TABLE p(i int) PARTITION BY RANGE(i);
> > CREATE TABLE s.c1 PARTITION OF p FOR VALUES FROM (1)TO(2);
> > CREATE TABLE s.c2 PARTITION OF p FOR VALUES FROM (2)TO(3);
> > ALTER TABLE p MERGE PARTITIONS (s.c1, s.c2) INTO s.c1; -- misbehaves if merging into the same name as an existing partition
> > \d+ p
> > ...
> > Partitions: c1 FOR VALUES FROM (1) TO (3)
>
> There is already a test which checks merging into the same name as an
> existing partition. And there are tests with schema-qualified names.
> I'm not yet convinced we need a test with both these properties
> together.

I mentioned that the combination of schemas and merge-into-same-name is
what currently doesn't work right.

> > Also, extended stats objects are currently cloned to new child tables.
> > But I suggested in [0] that they probably shouldn't be.
>
> I will explore this. Do we copy extended stats when we do CREATE
> TABLE ... PARTITION OF? I think we need to do the same here.

Right, they're not copied because an extended stats objs on the parent
does something different than putting stats objects on each child.
I've convinced myself that it's wrong to copy the parent's stats obj.
If someone wants stats objects on each child, they'll have to handle
them specially after MERGE/SPLIT, just as they would for per-child
defaults/constraints/etc.

On Sun, Apr 28, 2024 at 04:04:54AM +0300, Alexander Korotkov wrote:
> On Wed, Apr 24, 2024 at 11:26 PM Justin Pryzby <pryzby(at)telsasoft(dot)com> wrote:
> > This patch adds documentation saying:
> > + Any indexes, constraints and user-defined row-level triggers that exist
> > + in the parent table are cloned on new partitions [...]
> >
> > Which is good to say, and addresses part of my message [0]
> > [0] ZiJW1g2nbQs9ekwK(at)pryzbyj2023
>
> Makes sense. Extracted this into a separate patch in v10.

I adjusted the language some and fixed a typo in the commit message.

s/parition/partition/

--
Justin

Attachment Content-Type Size
0001-Document-the-way-partition-MERGE-SPLIT-operations-cr.patch text/x-diff 2.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David G. Johnston 2024-04-28 13:42:59 Re: Add SPLIT PARTITION/MERGE PARTITIONS commands
Previous Message Alexander Korotkov 2024-04-28 11:36:51 Re: Add SPLIT PARTITION/MERGE PARTITIONS commands