tableam options for pg_dump/ALTER/LIKE

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Andres Freund <andres(at)anarazel(dot)de>
Subject: tableam options for pg_dump/ALTER/LIKE
Date: 2020-01-28 13:33:17
Message-ID: 20200128133317.GZ13621@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I made these casual comments. If there's any agreement on their merit, it'd be
nice to implement at least the first for v13.

In <20190818193533(dot)GL11185(at)telsasoft(dot)com>, I wrote:
> . What do you think about pg_restore --no-tableam; similar to
> --no-tablespaces, it would allow restoring a table to a different AM:
> PGOPTIONS='-c default_table_access_method=zedstore' pg_restore --no-tableam ./pg_dump.dat -d postgres
> Otherwise, the dump says "SET default_table_access_method=heap", which
> overrides any value from PGOPTIONS and precludes restoring to new AM.

That appears to be a trivial variation on no-tablespace:

/* do nothing in --no-tablespaces mode */
if (ropt->noTablespace)
return;

> . it'd be nice if there was an ALTER TABLE SET ACCESS METHOD, to allow
> migrating data. Otherwise I think the alternative is:
> begin; lock t;
> CREATE TABLE new_t LIKE (t INCLUDING ALL EXCLUDING INDEXES) USING (zedstore);
> INSERT INTO new_t SELECT * FROM t;
> for index; do CREATE INDEX...; done
> DROP t; RENAME new_t (and all its indices). attach/inherit, etc.
> commit;

Ideally that would allow all at once various combinations of altering
tablespace, changing AM, clustering, and reindexing, like what's discussed
here:
https://www.postgresql.org/message-id/flat/8a8f5f73-00d3-55f8-7583-1375ca8f6a91(at)postgrespro(dot)ru

> . Speaking of which, I think LIKE needs a new option for ACCESS METHOD, which
> is otherwise lost.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dmitry Dolgov 2020-01-28 13:45:49 Re: Index Skip Scan
Previous Message Julien Rouhaud 2020-01-28 13:26:34 Re: Expose lock group leader pid in pg_stat_activity