Re: ALTER TABLE .. ADD PRIMARY KEY .. USING INDEX has dump-restore hazard

From: Gurjeet Singh <gurjeet(at)singh(dot)im>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ALTER TABLE .. ADD PRIMARY KEY .. USING INDEX has dump-restore hazard
Date: 2015-07-22 20:59:29
Message-ID: CABwTF4X+U8e5zZbf3hZhupvdQ2zhOzj=CzEJazvVGzQ16WTxew@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jul 21, 2015 at 9:23 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:

> rhaas=# create unique index on foo (a collate "C");
> CREATE INDEX
> rhaas=# alter table foo add primary key using index foo_a_idx;
> ALTER TABLE
>

> Now dump and restore this database. Then:
>

> Notice that the collation specifier is gone. Oops.
>

The intent of the 'USING INDEX' feature was to work around the problem that
PRIMARY KEY indexes cannot be reindexed concurrently to reduce bloat.

Considering that the feature doesn't work [1] (at least as shown in example
in the docs [2]) if there are any foreign keys referencing the table,
there's scope for improvement.

There was proposal to support reindexing the primary key index, but I am
not sure where that stands. If that's already in, or soon to be in core, we
may put a deprecation notice around USING INDEX. OTOH, if reindexing PKeys
is too difficult, we may want to support index-replacement via a top-level
ALTER TABLE subcommand that works in CONCURRENT mode, and not recommend the
method shown in the docs (i.e deprecate the USING INDEX syntax).

[1]: The DROP CONSTRAINT part of the command fails if there are any FKeys
pointing to this table.
[2]: http://www.postgresql.org/docs/9.4/static/sql-altertable.html

--
Gurjeet Singh http://gurjeet.singh.im/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dean Rasheed 2015-07-22 21:00:54 Re: psql :: support for \ev viewname and \sv viewname
Previous Message Robert Haas 2015-07-22 20:51:20 Re: [PATCH] postgres_fdw extension support