Re: Allow CLUSTER, VACUUM FULL and REINDEX to change tablespace on the fly
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Justin Pryzby <pryzby@telsasoft.com>
Cc: Alexey Kondratov <a.kondratov@postgrespro.ru>, Alvaro Herrera <alvherre@alvh.no-ip.org>, Peter Eisentraut <peter.eisentraut@enterprisedb.com>, Masahiko Sawada <masahiko.sawada@2ndquadrant.com>, Steve Singer <steve@ssinger.info>, pgsql-hackers@lists.postgresql.org, Robert Haas <robertmhaas@gmail.com>, Alexander Korotkov <a.korotkov@postgrespro.ru>, Masahiko Sawada <sawada.mshk@gmail.com>, Jose Luis Tallon <jltallon@adv-solutions.net>
Date: 2021-02-04T06:38:39Z
Lists: pgsql-hackers
On Wed, Feb 03, 2021 at 07:54:42PM +0900, Michael Paquier wrote: > Not sure I like that. Here is a proposal: > "it is recommended to separately use ALTER TABLE ONLY on them so as > any new partitions attached inherit the new tablespace value." So, I have done more work on this stuff today, and applied that as of c5b2860. While reviewing my changes, I have noticed that I have managed to break ALTER TABLE SET TABLESPACE which would have failed when cascading to a toast relation, the extra check placed previously in CheckRelationTableSpaceMove() being incorrect. The most surprising part was that we had zero in-core tests to catch this mistake, so I have added an extra test to cover this scenario while on it. A second thing I have come back to is allow_system_table_mods for toast relations, and decided to just forbid TABLESPACE if attempting to use it directly on a system table even if allow_system_table_mods is true. This was leading to inconsistent behaviors and weirdness in the concurrent case because all the indexes are processed in series after building a list. As we want to ignore the move of toast indexes when moving the indexes of the parent table, this was leading to extra conditions that are not really worth supporting after thinking about it. One other issue was the lack of consistency when using pg_global that was a no-op for the concurrent case but failed in the non-concurrent case. I have put in place more regression tests for all that. Regarding the VACUUM and CLUSTER cases, I am not completely sure if going through these for a tablespace case is the best move we can do, as ALTER TABLE is able to mix multiple operations and all of them require already an AEL to work. REINDEX was different thanks to the case of CONCURRENTLY. Anyway, as a lot of work has been done here already, I would recommend to create new threads about those two topics. I am also closing this patch in the CF app. -- Michael
Commits
-
Add TABLESPACE option to REINDEX
- c5b286047cd6 14.0 landed
-
Refactor code in tablecmds.c to check and process tablespace moves
- 4c9c359d38ff 14.0 landed
-
Refactor option handling of CLUSTER, REINDEX and VACUUM
- a3dc926009be 14.0 landed
-
pg_dump: Don't use enums for defining bit mask values
- d2a2808eb444 14.0 landed
-
Refactor CLUSTER and REINDEX grammar to use DefElem for option lists
- b5913f612079 14.0 landed
-
Refactor parsing rules for option lists of EXPLAIN, VACUUM and ANALYZE
- 873ea9ee692e 14.0 landed
-
Improve tab completion of REINDEX in psql
- 1f75b454134c 14.0 landed
-
Fix possible crash during FATAL exit from reindexing.
- d12bdba77b0f 13.0 cited