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 1lCWPJ-000609-21 for pgsql-hackers@arkaria.postgresql.org; Wed, 17 Feb 2021 23:38:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lCWOl-0000OR-UW for pgsql-hackers@arkaria.postgresql.org; Wed, 17 Feb 2021 23:38:23 +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 1lCWOl-0000Ny-JU for pgsql-hackers@lists.postgresql.org; Wed, 17 Feb 2021 23:38:23 +0000 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lCWOd-0002G0-0s for pgsql-hackers@postgresql.org; Wed, 17 Feb 2021 23:38:22 +0000 Received: by mail-ed1-x532.google.com with SMTP id z22so19303217edb.9 for ; Wed, 17 Feb 2021 15:38:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=subject:from:to:references:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=m7w0KSJ8zqFyaoHH4y1DsKE9RNefNHRGY1wNL8GUurU=; b=RC1K9roKn5PZPtTDklbk4agwVxtECe/z60VId/Lf/RuEVDc65QphsCPKGc4zkg9+VA f0znJ/QL7xIPSSMfMEf5tNA8hhIu6PwS8i0XWS9lH0EPGd30VheCYJUxmToCnucM2XkL FhjwPsq1KMcuRdyGXcVfcz5NjrBIBUtRRMB2PbXKLvi+p/OasLWaAcmNxZPtl/b2X9ae f1JupQRP2A2Rrwl10A64lRJJnCssU4cEj/G1wwghsH4YGuOLu4YlMGqDAtfV3KfNR8Bc qvnLqPXdYSx/J5l5M91Cc0YqCyWKW8ETDWH+44XqfwwI7Q3OBVn9rkQsTTCnt2okfxe5 7ghw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=m7w0KSJ8zqFyaoHH4y1DsKE9RNefNHRGY1wNL8GUurU=; b=pgRFZeo2sdFt1k/xQ/s7C620ZK3RWqB0kIB3jXl57ciWNN6eB5r6tDPejF+LFddWy0 Q8cjphU+0X3IoOSz2l67DT4RX3oSUfaiMz//2SRD8ZWZ9IFbQVjutySpulNcWxgxlKcj kM9bbw7mbHjrJbUqmF3uSYcKkxCQGLpWOKSYfG/bxkmJVmnW0qBs0b9T0G0n8bguiVL4 00yqFOxylx5ZhnhrXYifxAa0xok6vHAmTu08p5Z7RjR/MBSMBUFXmwPVGqgUhxhAE1Du iQtJVuG+TKcCi9iq3jK7YWWLZLuIf5EqXX1YbU1n9XzaOBM5OpNIFBRgnL5Vx4nKMcIw 5U9Q== X-Gm-Message-State: AOAM533R2Qtx9ebRgj4wYxwOowfmA3DTIswohHQnAi3Epmiz8MrB24L3 ZHVkKH1MI+bREHobbTMrlXh+lN/XX1Ce4CgrkdEJuhDTsDO21Jb71bfUQjG1NxGNrPvPV3bHc4+ 4lTJmD4IDNaPxLIz2lMEVYs9lSILYR2AGJG0RQgtE2Z1YTWlsHYMPWr9oWOW1pMaXaOHLePZ8Kg 8WOmi2ijq2tFNz9yRh6zbsh+/UIaboUBD6OyfM X-Google-Smtp-Source: ABdhPJwSkrZ60bcdjei3IQVG0igff4yws9dseFxihxT+BmpaQHPg41LvYenvCsTC85E2C6QQpyCbXA== X-Received: by 2002:aa7:d849:: with SMTP id f9mr1225830eds.76.1613605090979; Wed, 17 Feb 2021 15:38:10 -0800 (PST) Received: from [10.137.0.4] (ip-86-49-253-127.net.upcbroadband.cz. [86.49.253.127]) by smtp.gmail.com with ESMTPSA id p32sm1757906edd.96.2021.02.17.15.38.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 17 Feb 2021 15:38:10 -0800 (PST) Subject: Re: POC: postgres_fdw insert batching From: Tomas Vondra To: Amit Langote , PostgreSQL-development , "Tsunakawa, Takayuki" References: <20200628151002.7x5laxwpgvkyiu3q@development> <0fc809f6-7c3c-6d06-7ea3-f10765dfdf08@enterprisedb.com> <067ddf09-225c-e3c5-ea47-4dd39b34ebb0@enterprisedb.com> <7ffcee1f-d55e-cbdf-5f3f-98f1c30537ef@enterprisedb.com> <803d5507-299d-f109-7b71-b6bbbb17a053@enterprisedb.com> <6929d485-2d2a-da46-3681-4a400a3d794f@enterprisedb.com> Message-ID: Date: Thu, 18 Feb 2021 00:38:08 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <6929d485-2d2a-da46-3681-4a400a3d794f@enterprisedb.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2/17/21 8:36 PM, Tomas Vondra wrote: > > ... > > Thanks. The patch seems reasonable, but it's a bit too large for a fix, > so I'll go ahead and push one of the previous fixes restricting batching > to plain INSERT commands. But this seems useful, so I suggest adding it > to the next commitfest. I've pushed the v4 fix, adding the CMD_INSERT to execPartition. I think we may need to revise the relationship between FDW and places that (may) call GetForeignModifyBatchSize. Currently, these places need to be quite well synchronized - in a way, the issue was (partially) due to postgres_fdw and core not agreeing on the details. In particular, create_foreign_modify sets batch_size for CMD_INSERT and leaves it 0 otherwise. So GetForeignModifyBatchSize() returned 0 later, triggering an assert. It's probably better to require GetForeignModifyBatchSize() to always return a valid batch size (>= 1). If batching is not supported, just return 1. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company