Re: CLUSTER on partitioned index

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: 李杰(慎追) <adger(dot)lj(at)alibaba-inc(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, 曾文旌(义从) <wenjing(dot)zwj(at)alibaba-inc(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Zhihong Yu <zyu(at)yugabyte(dot)com>
Subject: Re: CLUSTER on partitioned index
Date: 2021-03-07 04:13:20
Message-ID: 20210307041320.GX29832@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Feb 10, 2021 at 02:04:58PM -0600, Justin Pryzby wrote:
> On Sat, Feb 06, 2021 at 08:45:49AM -0600, Justin Pryzby wrote:
> > On Mon, Jan 18, 2021 at 12:34:59PM -0600, Justin Pryzby wrote:
> > > On Sat, Nov 28, 2020 at 08:03:02PM -0600, Justin Pryzby wrote:
> > > > On Sun, Nov 15, 2020 at 07:53:35PM -0600, Justin Pryzby wrote:
> > > > > On Wed, Nov 04, 2020 at 08:23:56PM -0600, Justin Pryzby wrote:
> > > > > > On Tue, Oct 27, 2020 at 07:33:12PM -0500, Justin Pryzby wrote:
> > > > > > > I'm attaching a counter-proposal to your catalog change, which preserves
> > > > > > > indisclustered on children of clustered, partitioned indexes, and invalidates
> > > > > > > indisclustered when attaching unclustered indexes.
> > > > > >
> > > > > > ..and now propagates CLUSTER ON to child indexes.
> > > > > >
> > > > > > I left this as separate patches to show what I mean and what's new while we
> > > > > > discuss it.
> > > > >
> > > > > This fixes some omissions in the previous patch and error in its test cases.
> > > > >
> > > > > CLUSTER ON recurses to children, since I think a clustered parent index means
> > > > > that all its child indexes are clustered. "SET WITHOUT CLUSTER" doesn't have
> > > > > to recurse to children, but I did it like that for consistency and it avoids
> > > > > the need to special case InvalidOid.
> > > >
> > > > The previous patch failed pg_upgrade when restoring a clustered, parent index,
> > > > since it's marked INVALID until indexes have been built on all child tables, so
> > > > CLUSTER ON was rejected on invalid index.
> > > >
> > > > So I think CLUSTER ON needs to be a separate pg_dump object, to allow attaching
> > > > the child index (thereby making the parent "valid") to happen before SET
> > > > CLUSTER on the parent index.
> > >
> > > Rebased on b5913f612 and now a3dc92600.
> >
> > This resolves ORDER BY test failure with COLLATE "C".
>
> It occured to me that progress reporting should expose this.
>
> I did this in the style of pg_stat_progress_create_index, adding columns
> partitions_total and partitions_done showing the overall progress. The progress
> of individual partitions is also visible in {blocks,tuples}_{done,total}.
> This seems odd, but that's how the index view behaves.

Rebased on 8a8f4d8ede288c2a29105f4708e22ce7f3526149.

This also resolves an issue in the last patch which would've broken progress
reporting of vacuum full.

And take the suggestion to move memory context switching outside the loop.

--
Justin

Attachment Content-Type Size
v9-0001-pg_dump-make-CLUSTER-ON-a-separate-dump-object.patch text/x-diff 7.5 KB
v9-0002-Implement-CLUSTER-of-partitioned-table.patch text/x-diff 17.2 KB
v9-0003-f-progress-reporting.patch text/x-diff 10.9 KB
v9-0004-Propagate-changes-to-indisclustered-to-child-pare.patch text/x-diff 9.3 KB
v9-0005-Invalidate-parent-indexes.patch text/x-diff 3.6 KB
v9-0006-Invalidate-parent-index-cluster-on-attach.patch text/x-diff 3.1 KB
v9-0007-Preserve-indisclustered-on-children-of-clustered-.patch text/x-diff 3.0 KB
v9-0008-pg_dump-partitioned-index-depend-on-its-partition.patch text/x-diff 2.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhihong Yu 2021-03-07 04:49:58 Re: Parallel INSERT (INTO ... SELECT ...)
Previous Message Amit Kapila 2021-03-07 04:12:43 Re: Parallel INSERT (INTO ... SELECT ...)