Re: [HACKERS] Proposal: Local indexes for partitioned table

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Maksim Milyutin <milyutinma(at)gmail(dot)com>
Subject: Re: [HACKERS] Proposal: Local indexes for partitioned table
Date: 2017-12-15 22:18:01
Message-ID: 20171215221801.omgguzuor3ez7lre@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas wrote:
> On Fri, Dec 15, 2017 at 4:02 PM, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
> > 3. Robert's: use CREATE INDEX ON ONLY <parent>, which creates a shell
> > index on parent only (no recursion), followed by CREATE INDEX ON
> > <partition>. DETACH is not provided. If you ATTACH an index for a
> > partition that already has one index attached, then (1) the newly
> > attached one replaces the original (i.e. effectively REPLACE) or (2)
> > you get an error and we implement a separate ALTER INDEX REPLACE
> > command. It's not clear to me how or when the shell index becomes a
> > real index.
>
> With this proposal, I think the index can be invalid initially, but
> once you've attached an index for every child partition, it becomes
> irrevocably valid. After that, the only supported operation is
> REPLACE, which preserves validity.

Sounds okay to me. (I had already deleted ALTER INDEX DETACH from my
patch earlier today.) I admit I had also deleted the ONLY clause from
CREATE INDEX, and I don't like having to put it back :-) But on the
whole, having it sounds better than the alternatives.

We have two options for marking valid:

1. after each ALTER INDEX ATTACH, verify whether the set of partitions
that contain the index is complete; if so, mark it valid, otherwise do
nothing. This sucks because we have to check that over and over for
every index that we attach

2. We invent yet another command, say
ALTER INDEX <idx-on-parent> VALIDATE

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2017-12-15 22:31:50 "failed to find parent tuple for heap-only tuple" error as an ERRCODE_DATA_CORRUPTION ereport()
Previous Message Alvaro Herrera 2017-12-15 22:12:43 Re: [HACKERS] Proposal: Local indexes for partitioned table