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 1khNO7-0005zN-Vw for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Nov 2020 01:45:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1khNO6-0004oz-Vw for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Nov 2020 01:44:58 +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 1khNO6-0004oq-Le for pgsql-hackers@lists.postgresql.org; Tue, 24 Nov 2020 01:44:58 +0000 Received: from mail-ed1-x544.google.com ([2a00:1450:4864:20::544]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1khNNz-0005lJ-2u for pgsql-hackers@postgresql.org; Tue, 24 Nov 2020 01:44:58 +0000 Received: by mail-ed1-x544.google.com with SMTP id k1so6226738eds.13 for ; Mon, 23 Nov 2020 17:44:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Okw/GwNJgF3Pn9IV2Fip8R0s8uCB+ZCMJMakJNT1yt0=; b=QNj2uM48ifcf0YB5QWrwCkOuFg+4iLu1PGSKomOKjeYSl1V8p+sGtDU2cqKfZRCJfV UvzYVZ4JU54/j2fYKFC6Tqet53SmEAy9o3MmiWOb6twh+g8tqLqcQkUAwoEWxuP1DoLB zPQSRBxZ6mO9QoonS3bDDly690nf1FB3SuUNcbCNu1Hlmb660g+VWrDNM4SjfAQwfu68 RqUrzDmE25ngEqMoNrAKF3T2md0o999AzfjIdcd3RGy3wk4KGnJOVr63mLFJhanan44b xJOBhkfgkIRw2eov3J2vkkG+m63RmRAZPbwoRD6jQ78eI5KxGKhtfS7anbH2uUbRnqTf Vlog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Okw/GwNJgF3Pn9IV2Fip8R0s8uCB+ZCMJMakJNT1yt0=; b=FmRkHULRx8e7bbtfoSIDtH5ogf2EfekkZewUwIGaKKHNAcHGJlVT9VmSwxTZFY5Ku9 xvLxzrs/OI7rdBd4UYi3SZh7IGM+ZBDN09Sn5D6wQ+85lTm+huvzf99FEf+0CYcWDKA1 8adRFLI9+AThA6BSNytCJczBFTsHmzxo3+BGPL9lU95BJpa4DIzbf3Oe9BhiFA623auM gOoWELzDiFEKBvx0Uj08ql8Ihl33NThs0j13e0aTZPnCC9zSt4TurqhTAw0lvnvSNHTz hmeYQz3BG2W1ze39ikR/ovLoqKwM8TIMXCSQ0nG8VInpVi9cEF0vVsd1SamZ2y4FMDsb 7PgA== X-Gm-Message-State: AOAM531LIIkFVZLc8Rwe3od/fzcYiiDWM/msR8JVSOr7l4aJAZ3DSQn4 k/uF+2/0xxTiBOm8zvdSr7ebAc3LRcHWFEnmQNtF0i4m5ivcIBmt/d5AvOgSFLbwar/H0HlxKqA BTzXEFvjfIHnww+KmHaOoHdV9EC8M/MQp7t6QaPwq4xHy3YJsdZZLa8R/tFzwMXUSRH5I/W/1jB vhPeu6Xqwe46DQTvOtrF7HF3eJge9g3/taSXsDPnHZjcXIMje0xAj/u2l2HGLciMR/M0sNo+zCM v6cPUn7HjeCQGo2QsxEkRcZmwSby3H4DgQpNud0 X-Google-Smtp-Source: ABdhPJyQOKjdoUaSr6cRFiiLnISh/7ek30ay7c+Q0ICvKUdar1bYqFMj9JR28Ysxf8Z4WwFxRvgQLQ== X-Received: by 2002:aa7:d28d:: with SMTP id w13mr1799154edq.15.1606182288682; Mon, 23 Nov 2020 17:44:48 -0800 (PST) Received: from [10.137.0.18] (ip-86-49-245-76.net.upcbroadband.cz. [86.49.245.76]) by smtp.gmail.com with ESMTPSA id q5sm3018550ejr.89.2020.11.23.17.44.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 23 Nov 2020 17:44:47 -0800 (PST) Subject: Re: POC: postgres_fdw insert batching To: "tsunakawa.takay@fujitsu.com" Cc: 'Tomas Vondra' , "Andrey V. Lepikhov" , "pgsql-hackers@postgresql.org" References: <20200628151002.7x5laxwpgvkyiu3q@development> <0300d7df-854b-6f72-1e93-dfbf98f3fc8a@postgrespro.ru> <20200712001101.x65f3hvsanvamtgj@development> <20201008221421.foasnh5of66rupnm@development> <71113ab1-ed31-3dbc-ce07-e081e17473b6@enterprisedb.com> From: Tomas Vondra Message-ID: <43b5d643-da69-70a5-16d2-d04d0851b723@enterprisedb.com> Date: Tue, 24 Nov 2020 02:44:45 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: 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 11/23/20 3:17 AM, tsunakawa.takay@fujitsu.com wrote: > From: Tomas Vondra >> I don't think this is usable in practice, because a single session >> may be using multiple FDW servers, with different implementations, >> latency to the data nodes, etc. It's unlikely a single GUC value >> will be suitable for all of them. > > That makes sense. The row size varies from table to table, so the > user may want to tune this option to reduce memory consumption. > > I think the attached patch has reflected all your comments. I hope > this will pass.. > Thanks - I didn't have time for a thorough review at the moment, so I only skimmed through the diff and did a couple very simple tests. And I think overall it looks quite nice. A couple minor comments/questions: 1) We're calling it "batch_size" but the API function is named postgresGetMaxBulkInsertTuples(). Perhaps we should rename the function to postgresGetModifyBatchSize()? That has the advantage it'd work if we ever add support for batching to UPDATE/DELETE. 2) Do we have to lookup the batch_size in create_foreign_modify (in server/table options)? I'd have expected to look it up while planning the modify and then pass it through the list, just like the other FdwModifyPrivateIndex stuff. But maybe that's not possible. 3) That reminds me - should we show the batching info on EXPLAIN? That seems like a fairly interesting thing to show to the user. Perhaps showing the average batch size would also be useful? Or maybe not, we create the batches as large as possible, with the last one smaller. 4) It seems that ExecInsert executes GetMaxBulkInsertTuples() over and over for every tuple. I don't know it that has measurable impact, but it seems a bit excessive IMO. I don't think we should support the batch size changing during execution (seems tricky). regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company