Re: ALTER tbl rewrite loses CLUSTER ON index
Justin Pryzby <pryzby@telsasoft.com>
From: Justin Pryzby <pryzby@telsasoft.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>, Amit Langote <amitlangote09@gmail.com>, pgsql-hackers@postgresql.org, Michael Paquier <michael@paquier.xyz>
Date: 2020-02-29T02:42:02Z
Lists: pgsql-hackers
On Fri, Feb 28, 2020 at 06:26:04PM -0500, Tom Lane wrote: > Justin Pryzby <pryzby@telsasoft.com> writes: > > I think the attached is 80% complete (I didn't touch pg_dump). > > One objection to this change would be that all relations (including indices) > > end up with relclustered fields, and pg_index already has a number of bools, so > > it's not like this one bool is wasting a byte. > > I think relisclustered was a's clever way of avoiding that overhead (c0ad5953). > > So I would be -0.5 on moving it to pg_class.. > > But I think 0001 and 0002 are worthy. Maybe the test in 0002 should live > > somewhere else. > > 0001 has been superseded by events (faade5d4c), so the cfbot is choking > on that one's failure to apply, and not testing any further. Please > repost without 0001 so that we can get this testing again. I've just noticed while working on (1) that this separately affects REINDEX CONCURRENTLY, which would be a new bug in v12. Without CONCURRENTLY there's no issue. I guess we need a separate patch for that case. (1) https://commitfest.postgresql.org/27/2269/ The ALTER bug goes back further and its fix should be a kept separate. postgres=# DROP TABLE tt; CREATE TABLE tt(i int unique); CLUSTER tt USING tt_i_key; CLUSTER tt; REINDEX INDEX tt_i_key; CLUSTER tt; DROP TABLE CREATE TABLE CLUSTER CLUSTER REINDEX CLUSTER postgres=# DROP TABLE tt; CREATE TABLE tt(i int unique); CLUSTER tt USING tt_i_key; CLUSTER tt; REINDEX INDEX CONCURRENTLY tt_i_key; CLUSTER tt; DROP TABLE CREATE TABLE CLUSTER CLUSTER REINDEX ERROR: there is no previously clustered index for table "tt" -- Justin
Commits
-
Refactor cluster.c to use new routine get_index_isclustered()
- 8ef9451f58ee 13.0 landed
-
Preserve clustered index after rewrites with ALTER TABLE
- 3f77a670241d 9.5.22 landed
- 61a161fe4421 9.6.18 landed
- cef2b8d52c59 10.13 landed
- 41faafbd75a5 11.8 landed
- 3e62dd3a937b 12.3 landed
- a40caf5f862c 13.0 landed
-
Preserve replica identity index across ALTER TABLE rewrite
- 1cc9c2412cc9 13.0 cited
-
Remove RangeIOData->typiofunc
- a77315fdf2a1 13.0 cited
-
Preserve pg_index.indisclustered across REINDEX CONCURRENTLY
- f087d63a45b5 12.3 landed
- d79fb88ac738 13.0 landed