Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kFZwG-0002VL-4N for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Sep 2020 09:29:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kFZwF-0002GL-1m for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Sep 2020 09:29:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kFZwE-0002GA-RH for pgsql-hackers@lists.postgresql.org; Tue, 08 Sep 2020 09:29:18 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kFZwC-0005F0-8L for pgsql-hackers@postgresql.org; Tue, 08 Sep 2020 09:29:18 +0000 Received: from mail.postgrespro.ru (cyclops.postgrespro.ru [93.174.131.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 07F5321C337E; Tue, 8 Sep 2020 12:29:15 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1599557355; bh=NunBDEWMKpfvvCzowmvpkqU9APNVhOO+m7vS3Vp1qrU=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=B9yh6msYoK6UF9quimzhMtfl3qlDMQvaV5JoHZhdt455Px4AVw8iR5kUy/j51/MwT k6x994dgliQdCiU08GFEt/8umrUUDMOLWPxlJ8rAhL0/XF7GNPlaDwWQ/5eWy2edp4 aOyYYRn0l4P6813vUgmrgFcVueEejQKdocJUWw88= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 08 Sep 2020 12:29:14 +0300 From: Alexey Kondratov To: Amit Langote Cc: "Andrey V. Lepikhov" , Michael Paquier , Ashutosh Bapat , Ashutosh Bapat , Etsuro Fujita , PostgreSQL-Dev Subject: Re: [POC] Fast COPY FROM command for the table with foreign partitions In-Reply-To: References: <9a65d03b-250f-b086-5a3c-541d8e2de30d@postgrespro.ru> <20200907072651.GF4867@paquier.xyz> <19ba27e7-ee1e-9117-68ad-fd609b5763ca@postgrespro.ru> User-Agent: Roundcube Webmail/1.4.0 Message-ID: <0c67618c2e43b1dccb260dd6f90eeac2@postgrespro.ru> X-Sender: a.kondratov@postgrespro.ru List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, I've started doing a review of v7 yesterday. On 2020-09-08 10:34, Amit Langote wrote: > On Mon, Sep 7, 2020 at 7:31 PM Andrey V. Lepikhov > wrote: >> > >> v.7 (in attachment) fixes this problem. >> I also accepted Amit's suggestion to rename all fdwapi routines such >> as >> ForeignCopyIn to *ForeignCopy. > It seems that naming is quite inconsistent now: + /* COPY a bulk of tuples into a foreign relation */ + BeginForeignCopyIn_function BeginForeignCopy; + EndForeignCopyIn_function EndForeignCopy; + ExecForeignCopyIn_function ExecForeignCopy; You get rid of this 'In' in the function names, but the types are still with it: +typedef void (*BeginForeignCopyIn_function) (ModifyTableState *mtstate, + ResultRelInfo *rinfo); + +typedef void (*EndForeignCopyIn_function) (EState *estate, + ResultRelInfo *rinfo); + +typedef void (*ExecForeignCopyIn_function) (ResultRelInfo *rinfo, + TupleTableSlot **slots, + int nslots); Also docs refer to old function names: +void +BeginForeignCopyIn(ModifyTableState *mtstate, + ResultRelInfo *rinfo); I think that it'd be better to choose either of these two naming schemes and use it everywhere for consistency. > > Any thoughts on the taking out the refactoring changes out of the main > patch as I suggested? > +1 for splitting the patch. It was rather difficult for me to distinguish changes required by COPY via postgres_fdw from this refactoring. Another ambiguous part of the refactoring was in changing InitResultRelInfo() arguments: @@ -1278,6 +1280,7 @@ InitResultRelInfo(ResultRelInfo *resultRelInfo, Relation resultRelationDesc, Index resultRelationIndex, Relation partition_root, + bool use_multi_insert, int instrument_options) Why do we need to pass this use_multi_insert flag here? Would it be better to set resultRelInfo->ri_usesMultiInsert in the InitResultRelInfo() unconditionally like it is done for ri_usesFdwDirectModify? And after that it will be up to the caller whether to use multi-insert or not based on their own circumstances. Otherwise now we have a flag to indicate that we want to check for another flag, while this check doesn't look costly. Regards -- Alexey Kondratov Postgres Professional https://www.postgrespro.com Russian Postgres Company