Re: TRUNCATE on foreign table
Kohei KaiGai <kaigai@heterodb.com>
From: Kohei KaiGai <kaigai@heterodb.com>
To: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Cc: Zhihong Yu <zyu@yugabyte.com>, Kazutaka Onishi <onishi@heterodb.com>, Fujii Masao <masao.fujii@oss.nttdata.com>,
Amit Langote <amitlangote09@gmail.com>, Ibrar Ahmed <ibrar.ahmad@gmail.com>, PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>, Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Date: 2021-04-04T05:13:39Z
Lists: pgsql-hackers
2021年4月4日(日) 13:07 Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>: > > On Sat, Apr 3, 2021 at 8:31 PM Zhihong Yu <zyu@yugabyte.com> wrote: > > w.r.t. Bharath's question on using hash table, I think the reason is that the search would be more efficient: > > Generally, sequential search would be slower if there are many entries > in a list. Here, the use case is to store all the foreign table ids > associated with each foreign server and I'm not sure how many foreign > tables will be provided in a single truncate command that belong to > different foreign servers. I strongly feel the count will be less and > using a list would be easier than to have a hash table. Others may > have better opinions. > https://www.postgresql.org/message-id/20200115081126.GK2243@paquier.xyz It was originally implemented using a simple list, then modified according to the comment by Michael. I think it is just a matter of preference. > > Should the hash table be released at the end of ExecuteTruncateGuts() ? > > If we go with a hash table and think that the frequency of "TRUNCATE" > commands on foreign tables is heavy in a local session, then it does > make sense to not destroy the hash, otherwise destroy the hash. > In most cases, TRUNCATE is not a command frequently executed. So, exactly, it is just a matter of preference. Best regards, -- HeteroDB, Inc / The PG-Strom Project KaiGai Kohei <kaigai@heterodb.com>
Commits
-
doc: Review for "Allow TRUNCATE command to truncate foreign tables".
- 0c8f40863acb 14.0 landed
-
Don't pass "ONLY" options specified in TRUNCATE to foreign data wrapper.
- 8e9ea08bae93 14.0 landed
-
Support tab-complete for TRUNCATE on foreign tables.
- 81e094bdfdd6 14.0 landed
-
Allow TRUNCATE command to truncate foreign tables.
- 8ff1c94649f5 14.0 landed
-
Add support for asynchronous execution.
- 27e1f14563cf 14.0 cited