Re: TRUNCATE on foreign tables - Mailing list pgsql-hackers

From Kohei KaiGai
Subject Re: TRUNCATE on foreign tables
Date
Msg-id CAOP8fzZktmZ0s1oEV5o6t2s=fePGpY6jOpb3+E6mB-C0X4X6OA@mail.gmail.com
Whole thread Raw
In response to Re: TRUNCATE on foreign tables  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Responses Re: TRUNCATE on foreign tables  (Stephen Frost <sfrost@snowman.net>)
List pgsql-hackers
2020年1月2日(木) 20:56 Alvaro Herrera <alvherre@2ndquadrant.com>:
>
> On 2020-Jan-02, Kohei KaiGai wrote:
>
> > 2020年1月2日(木) 12:16 Alvaro Herrera <alvherre@2ndquadrant.com>:
> > >
> > > I think this would need to preserve the notion of multi-table truncates.
> > > Otherwise it won't be possible to truncate tables linked by FKs.  I
> > > think this means the new entrypoint needs to receive a list of rels to
> > > truncate, not just one.  (Maybe an alternative is to make it "please
> > > truncate rel X, and be aware that relations Y,Z are also being
> > > truncated at the same time".)
> >
> > Please check at ExecuteTruncateGuts(). It makes a list of relations to be
> > truncated, including the relations that references the specified table by FK,
> > prior to invocation of the new FDW callback.
> > So, if multiple foreign tables are involved in a single TRUNCATE command,
> > this callback can be invoked multiple times.
>
> Yeah, that's my concern: if you have postgres_fdw tables linked by FKs
> in the remote server, the truncate will fail because it'll try to
> truncate them in separate commands instead of using a multi-table
> truncate.
>
Ah, it makes sense.
Probably, backend can make sub-list of the foreign tables to be
truncated for each
pair of FDW and Server, then invoke the FDW callback only once with this list.
FDW driver can issue multi-tables truncate on all the foreign tables
supplied, with
nothing difficult to do.

Best regards,
--
HeteroDB, Inc / The PG-Strom Project
KaiGai Kohei <kaigai@heterodb.com>



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Decade indication
Next
From: Pavel Stehule
Date:
Subject: Re: Refactor parse analysis of EXECUTE command