From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: Kohei KaiGai <kaigai@heterodb.com>
To: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Cc: Kazutaka Onishi <onishi@heterodb.com>
Cc: Zhihong Yu <zyu@yugabyte.com>
Cc: Amit Langote <amitlangote09@gmail.com>
Cc: Ibrar Ahmed <ibrar.ahmad@gmail.com>
Cc: PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Cc: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Subject: Re: TRUNCATE on foreign table
Date: Wed, 14 Apr 2021 00:00:14 +0900
Message-ID: <70310892-3572-f143-a692-e9aa4322a914@oss.nttdata.com> (raw)
In-Reply-To: <CAOP8fzYbU2g4wFJAcxJkaESWV1NxJL3LYf=jXti-JL3fcvPgxw@mail.gmail.com>
References: <CAJuF6cMWDDqU-vn_knZgma+2GMaout68YUgn1uyDnexRhqqM5Q@mail.gmail.com>
<CAOP8fzajfK4vUe0s0YAOehjaFxvcecdvv2JdzeR6mZ-V3fLVbw@mail.gmail.com>
<d5df2e94-f643-6409-5cd4-fa1c2ebd41fa@oss.nttdata.com>
<CAOP8fzbKh1V_n-huDmzxQRsMRZ5qNb+2wo5khKOrweGgx6pBrg@mail.gmail.com>
<43f71643-5068-8a77-4bda-005b0ff7bd4f@oss.nttdata.com>
<CAOP8fzYY=xkj_ke3h-cHO08S6WKfcja0uNPmGjNYo50rm66+6Q@mail.gmail.com>
<551ed8c1-f531-818b-664a-2cecdab99cd8@oss.nttdata.com>
<CAOP8fzaWkX7O3QmKtJ9DEtBfwaR5+OL2KfycnYNrxPC9zEG2QQ@mail.gmail.com>
<eac9329f-f285-2044-1974-b3d0d0aa5950@oss.nttdata.com>
<CAOP8fzYgM=bxsDgtnucx4k_QUdUknri4UEdPxr9bkkfqRYoRog@mail.gmail.com>
<CAOP8fzZf+=RQFmwLRw5s1KKgApuXmYPC76nmUZGck4=e7AJj8Q@mail.gmail.com>
<2209ecd8-0382-cbcb-5717-15da49535237@oss.nttdata.com>
<CAOP8fzbCfju6TT4DYqw5KC9tgTN4UzpagJnY3WRXfiR9R58M1Q@mail.gmail.com>
<CALj2ACVuygqS7rMGHGs-W_JGx6pjdAFitTZuNfWdV2QaBaOc+A@mail.gmail.com>
<CAOP8fzYbU2g4wFJAcxJkaESWV1NxJL3LYf=jXti-JL3fcvPgxw@mail.gmail.com>
On 2021/04/13 23:25, Kohei KaiGai wrote:
> 2021年4月13日(火) 21:03 Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>:
>> Yeah, ONLY clause is not pushed to the remote server in case of SELECT
>> commands. This is also true for DELETE and UPDATE commands on foreign
>> tables.
This sounds reasonable reason why ONLY should be ignored in TRUNCATE on
foreign tables, for now. If there is the existing rule about how to treat
ONLY clause for foreign tables, basically TRUNCATE should follow that at this
stage. Maybe we can change the rule, but it's an item for v15 or later?
>> I'm not sure if it wasn't thought necessary or if there is an
>> issue to push it or I may be missing something here.
I could not find the past discussion about foreign tables and ONLY clause.
I guess that ONLY is ignored in SELECT on foreign tables case because ONLY
is interpreted outside the executor and it's not easy to change the executor
so that ONLY is passed to FDW. Maybe..
>> I think we can
>> start a separate thread to see other hackers' opinions on this.
>>
>> I'm not sure whether all the clauses that are possible for
>> SELECT/UPDATE/DELETE/INSERT with local tables are pushed to the remote
>> server by postgres_fdw.
>>
>> Well, now foreign TRUNCATE pushes the ONLY clause to the remote server
>> which is inconsistent when compared to SELECT/UPDATE/DELETE commands.
>> If we were to keep it consistent across all foreign commands that
>> ONLY clause is not pushed to remote server, then we can restrict for
>> TRUNCATE too and even if "TRUNCATE ONLY foreign_tbl" is specified,
>> just pass "TRUNCATE foreign_tbl" to remote server. Having said that, I
>> don't see any real problem in pushing the ONLY clause, at least in
>> case of TRUNCATE.
>>
> If ONLY-clause would be pushed down to the remote query of postgres_fdw,
> what does the foreign-table represent in the local system?
>
> In my understanding, a local foreign table by postgres_fdw is a
> representation of
> entire tree of the remote parent table and its children.
If so, I'm still wondering why CASCADE/RESTRICT (i.e., DropBehavior) needs to
be passed to FDW. IOW, if a foreign table is an abstraction of an external
data source, ISTM that postgres_fdw should always issue TRUNCATE with
CASCADE. Why do we need to allow RESTRICT to be specified for a foreign table
even though it's an abstraction of an external data source?
Regards,
--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: masao.fujii@oss.nttdata.com, kaigai@heterodb.com, bharath.rupireddyforpostgres@gmail.com, onishi@heterodb.com, zyu@yugabyte.com, amitlangote09@gmail.com, ibrar.ahmad@gmail.com, ashutosh.bapat.oss@gmail.com
Subject: Re: TRUNCATE on foreign table
In-Reply-To: <70310892-3572-f143-a692-e9aa4322a914@oss.nttdata.com>
References: <CAJuF6cMWDDqU-vn_knZgma+2GMaout68YUgn1uyDnexRhqqM5Q@mail.gmail.com> <d5df2e94-f643-6409-5cd4-fa1c2ebd41fa@oss.nttdata.com> <CAOP8fzbKh1V_n-huDmzxQRsMRZ5qNb+2wo5khKOrweGgx6pBrg@mail.gmail.com> <43f71643-5068-8a77-4bda-005b0ff7bd4f@oss.nttdata.com> <CAOP8fzYY=xkj_ke3h-cHO08S6WKfcja0uNPmGjNYo50rm66+6Q@mail.gmail.com> <551ed8c1-f531-818b-664a-2cecdab99cd8@oss.nttdata.com> <CAOP8fzaWkX7O3QmKtJ9DEtBfwaR5+OL2KfycnYNrxPC9zEG2QQ@mail.gmail.com> <eac9329f-f285-2044-1974-b3d0d0aa5950@oss.nttdata.com> <CAOP8fzYgM=bxsDgtnucx4k_QUdUknri4UEdPxr9bkkfqRYoRog@mail.gmail.com> <CAOP8fzZf+=RQFmwLRw5s1KKgApuXmYPC76nmUZGck4=e7AJj8Q@mail.gmail.com> <2209ecd8-0382-cbcb-5717-15da49535237@oss.nttdata.com> <CAOP8fzbCfju6TT4DYqw5KC9tgTN4UzpagJnY3WRXfiR9R58M1Q@mail.gmail.com> <CALj2ACVuygqS7rMGHGs-W_JGx6pjdAFitTZuNfWdV2QaBaOc+A@mail.gmail.com> <CAOP8fzYbU2g4wFJAcxJkaESWV1NxJL3LYf=jXti-JL3fcvPgxw@mail.gmail.com> <70310892-3572-f143-a692-e9aa4322a914@oss.nttdata.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox