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: Alexey Kondratov <a.kondratov@postgrespro.ru>
Cc: Robert Haas <robertmhaas@gmail.com>, Surafel Temesgen <surafel3000@gmail.com>, Alexander Korotkov <a.korotkov@postgrespro.ru>, Masahiko Sawada <sawada.mshk@gmail.com>, Alvaro Herrera <alvherre@2ndquadrant.com>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2019-09-20T02:06:34Z
Lists: pgsql-hackers
On Thu, Sep 19, 2019 at 05:40:41PM +0300, Alexey Kondratov wrote: > On 19.09.2019 16:21, Robert Haas wrote: >> So, earlier in this thread, I suggested making this part of ALTER >> TABLE, and several people seemed to like that idea. Did we have a >> reason for dropping that approach? Personally, I don't find this idea very attractive as ALTER TABLE is already complicated enough with all the subqueries we already support in the command, all the logic we need to maintain to make combinations of those subqueries in a minimum number of steps, and also the number of bugs we have seen because of the amount of complication present. > If we add this option to REINDEX, then for 'ALTER TABLE tb_name action1, > REINDEX SET TABLESPACE tbsp_name, action3' action2 will be just a direct > alias to 'REINDEX TABLE tb_name SET TABLESPACE tbsp_name'. So it seems > practical to do this for REINDEX first. > > The only one concern I have against adding REINDEX to ALTER TABLE in this > context is that it will allow user to write such a chimera: > > ALTER TABLE tb_name REINDEX SET TABLESPACE tbsp_name, SET TABLESPACE > tbsp_name; > > when they want to move both table and all the indexes. Because simple > ALTER TABLE tb_name REINDEX, SET TABLESPACE tbsp_name; > looks ambiguous. Should it change tablespace of table, indexes or both? Tricky question, but we don't change the tablespace of indexes when using an ALTER TABLE, so I would say no on compatibility grounds. ALTER TABLE has never touched the tablespace of indexes, and I don't think that we should begin to do so. -- 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