Re: TRUNCATE on foreign tables

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Kohei KaiGai <kaigai(at)heterodb(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TRUNCATE on foreign tables
Date: 2020-01-02 11:56:40
Message-ID: 20200102115640.GA30335@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2020-Jan-02, Kohei KaiGai wrote:

> 2020年1月2日(木) 12:16 Alvaro Herrera <alvherre(at)2ndquadrant(dot)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.

> > Looking at apache arrow documentation, it doesn't appear that it has
> > anything like FK constraints.
> >
> Yes. It is just a bunch of columnar data.
> In Apache Arrow, no constraint are defined except for "NOT NULL".
> (In case when Field::nullable == false, all the values are considered
> valid date.)

OK, I suppose that means there are no concerns such as what I mention
above.

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2020-01-02 12:08:50 parallel vacuum options/syntax
Previous Message Dilip Kumar 2020-01-02 10:31:37 Re: [HACKERS] Block level parallel vacuum