Re: Change a constraint's index - ALTER TABLE ... ALTER CONSTRAINT ... USING INDEX ...
От
Laurenz Albe
Тема
Re: Change a constraint's index - ALTER TABLE ... ALTER CONSTRAINT ... USING INDEX ...
Дата
Msg-id
07f866b37e7bac976aff0e0fe8d74906e1e69c45.camel@cybertec.at
Ответ на
Re: Change a constraint's index - ALTER TABLE ... ALTER CONSTRAINT ... USING INDEX ... (Anna Akenteva)
Список
Дерево обсуждения
Change a constraint's index - ALTER TABLE ... ALTER CONSTRAINT ... USING INDEX ... Anna Akenteva <a.akenteva@postgrespro.ru>
Re: Change a constraint's index - ALTER TABLE ... ALTER CONSTRAINT ... USING INDEX ... Alvaro Herrera <alvherre@2ndquadrant.com>
Re: Change a constraint's index - ALTER TABLE ... ALTER CONSTRAINT ... USING INDEX ... Tom Lane <tgl@sss.pgh.pa.us>
Re: Change a constraint's index - ALTER TABLE ... ALTER CONSTRAINT ... USING INDEX ... Anna Akenteva <a.akenteva@postgrespro.ru>
Re: Change a constraint's index - ALTER TABLE ... ALTER CONSTRAINT ... USING INDEX ... Laurenz Albe <laurenz.albe@cybertec.at>
Re: Change a constraint's index - ALTER TABLE ... ALTER CONSTRAINT ... USING INDEX ... Alvaro Herrera <alvherre@2ndquadrant.com>
Re: Change a constraint's index - ALTER TABLE ... ALTER CONSTRAINT ... USING INDEX ... Laurenz Albe <laurenz.albe@cybertec.at>
Re: Change a constraint's index - ALTER TABLE ... ALTER CONSTRAINT ... USING INDEX ... Alvaro Herrera <alvherre@2ndquadrant.com>
Re: Change a constraint's index - ALTER TABLE ... ALTER CONSTRAINT ... USING INDEX ... Laurenz Albe <laurenz.albe@cybertec.at>
Re: Change a constraint's index - ALTER TABLE ... ALTER CONSTRAINT ... USING INDEX ... Alvaro Herrera <alvherre@2ndquadrant.com>
Re: Change a constraint's index - ALTER TABLE ... ALTER CONSTRAINT ... USING INDEX ... Laurenz Albe <laurenz.albe@cybertec.at>
Re: Change a constraint's index - ALTER TABLE ... ALTER CONSTRAINT ... USING INDEX ... Alvaro Herrera <alvherre@2ndquadrant.com>
On Mon, 2020-08-10 at 09:29 +0300, Anna Akenteva wrote: > On 2020-07-07 01:08, Tom Lane wrote: > > > Alvaro Herrera writes: > > > On 2020-Jul-05, Anna Akenteva wrote: > > > > -- Swapping primary key's index for an equivalent index, > > > > -- but with INCLUDE-d attributes. > > > > CREATE UNIQUE INDEX new_idx ON target_tbl (id) INCLUDE (info); > > > > ALTER TABLE target_tbl ALTER CONSTRAINT target_tbl_pkey USING INDEX > > > > new_idx; > > > > ALTER TABLE referencing_tbl ALTER CONSTRAINT > > > > referencing_tbl_id_ref_fkey > > > > USING INDEX new_idx; > > > How is this state represented by pg_dump? > > Even if it's possible to represent, I think we should flat out reject > > this "feature". Primary keys that aren't primary keys don't seem like > > a good idea. For one thing, it won't be possible to describe the > > constraint accurately in the information_schema. > > > Do you think it could still be a good idea if we only swap the > relfilenodes of indexes, as it was suggested in [1]? The original use > case was getting rid of index bloat, which is now solved by REINDEX > CONCURRENTLY, but this feature still has its own use case of adding > INCLUDE-d columns to constraint indexes. How can you just swap the filenodes if "indnatts" and "indkey" is different, since one index has an INCLUDE clause? I think that the original proposal is better, except that foreign key dependencies should be changed along with the primary or unique index, so that everything is consistent once the command is done. Then the ALTER CONSTRAINT from that replaces the index referenced by a foreign key becomes unnecessary and should be removed. The value I see in this is: - replacing a primary key index - replacing the index behind a constraint targeted by a foreign key Some code comments: + + ALTER CONSTRAINT constraint_name [USING INDEX
В списке pgsql-hackers по дате отправления
От: Ashutosh Bapat
Дата: