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 1jtkec-0005C1-IA for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Jul 2020 04:28:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jtkeb-0003qX-FI for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Jul 2020 04:28:53 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jtkeb-0003qG-4U for pgsql-hackers@lists.postgresql.org; Fri, 10 Jul 2020 04:28:53 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jtkeX-00035Q-IA for pgsql-hackers@postgresql.org; Fri, 10 Jul 2020 04:28:52 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id D7AE021C75DE; Fri, 10 Jul 2020 07:28:45 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from [192.168.129.197] (unknown [94.25.177.252]) (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 7C8C821C74DB; Fri, 10 Jul 2020 07:28:45 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1594355325; bh=FHzHJuWYv2xMyWTxJNZNLt3/jEO2NBAk2AkmOBcohuk=; h=Subject:To:References:From:Date:In-Reply-To; b=LOIIwXIaeoSjM5f1626TsUo6hzLS2L+P1w1Z1m5CiN97UpNJbpKYKhSj+u/WrkICe YkiZvk8h4u5UFlsxhhnIUUNaRzODr/18frYDC7iyvMH0Le/y+I2l31GUQpCdc5yIyX 3xKKgnWW+kQ6HdBkcnSGXMkMmISYohW0YIdUiu6Q= Subject: Re: POC: postgres_fdw insert batching To: Tomas Vondra , pgsql-hackers@postgresql.org References: <20200628151002.7x5laxwpgvkyiu3q@development> From: "Andrey V. Lepikhov" Organization: Postgres Professional Message-ID: <0300d7df-854b-6f72-1e93-dfbf98f3fc8a@postgrespro.ru> Date: Fri, 10 Jul 2020 09:28:44 +0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200628151002.7x5laxwpgvkyiu3q@development> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 6/28/20 8:10 PM, Tomas Vondra wrote: > Now, the primary reason why the performance degrades like this is that > while FDW has batching for SELECT queries (i.e. we read larger chunks of > data from the cursors), we don't have that for INSERTs (or other DML). > Every time you insert a row, it has to go all the way down into the > partition synchronously. You added new fields into the PgFdwModifyState struct. Why you didn't reused ResultRelInfo::ri_CopyMultiInsertBuffer field and CopyMultiInsertBuffer machinery as storage for incoming tuples? -- regards, Andrey Lepikhov Postgres Professional