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 1l1tRV-0001jt-7G for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Jan 2021 16:01:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l1tRT-0004sE-9G for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Jan 2021 16:01:15 +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 1l1tRT-0004s7-1v for pgsql-hackers@lists.postgresql.org; Tue, 19 Jan 2021 16:01:15 +0000 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1l1tRP-0007OU-8d for pgsql-hackers@postgresql.org; Tue, 19 Jan 2021 16:01:14 +0000 Received: by mail-ed1-x52a.google.com with SMTP id s11so14847622edd.5 for ; Tue, 19 Jan 2021 08:01:10 -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=eSLUmrxVSdWU58ggVU1n2pYjwGHjvm+CqU2KCY75AjI=; b=ZWk2AjGBOND9/yTomPVMsJmKHiiJqVuZUs44riOaUwTN0jMpuOtKTmYbPm3Fci8/Pf q2zraapgnpoGYAb9aOdTz3O9SGKz//zzLKSg5ol87rzTJ24MYQqUlYqKNDYebtxQvHZD JRlbiks4Zr5LWff89+pSN7e+knrhCEU1vKeTPsEKio58rmyfRxpstecSZD5OYbqXIIc+ byqO1n//x+j9ALIdBvgUIoQylsop1krv7B3S0BJXCMa6XPkFCGmw5/nPzuuokLH+0K3g Dc0XTa6kcIZyGhyv2iO3kXzkeJj6AWJoZ/GTfz0L0goGvB5DLIN/U8rA/lL2XsSJX3sT f/0A== 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=eSLUmrxVSdWU58ggVU1n2pYjwGHjvm+CqU2KCY75AjI=; b=hnj1Bb8jnpHs5fykJcx/d8xl2sTPR9VYMK9XYkvQD/RN7ky+J3bVqT/2VaUixNaJTJ CzMbfx4iYtdMUzkD2lGXnU4EObiLchd+rHVmFxhl8EGEh+abhTi2ZT0yqYQ9ybmDdkzr wMm7H+J9clkFl4wBWgB5oPmfnQsnz9B5tsJus4+aa3uIfCFDmLN9Tf0UdBi732OictGn 3Mx1g+hqjtKJmhGi4M3alnlLltAvyspYk5t2V/YWzRK6cFSJ9GlqcT8P+I8A8fiFneWY EuyIHVd6WNZXB4ZsOcr/Q+w2JEMsKLv9MwwAhBMC6PCFijIXtynvNkkfTPDfqAotFHiq 9+JA== X-Gm-Message-State: AOAM533j1HTusoJwsiIm38Sj0/4X9peyJDKk8ZLMhT96NZs239K3ack2 GDH3e63rqRAyuoqdb9fs37FHpaU2nYage3F6f2lBGb5e2SlRgxSguYS7ECwwS/JPO1xUmjJsY5G dCJTObtAjuw0q9qbLf4s6r+crD5EJXDSG06/bs/Oi8Z199QzdiTnBG+DijzFtJKH26HGOe4fAEo U9flMQE1sYA6GVQjlIwPVCPjrEgI6PPfV51HZMQOwtS6mxK5GlCICwEO7CfjB6S6MccF6BCvGGM 7USNTNMMg7gsEWV9oVf3djzRCz67wOZkLJj8kP2 X-Google-Smtp-Source: ABdhPJwFD5adz3J9wfHISWOAMKDLUSPb6lzejcz7rijjzPHQi+RpQcnw86A4Ho3rUVCF9jGe5HDA4w== X-Received: by 2002:a05:6402:524a:: with SMTP id t10mr4055988edd.270.1611072069436; Tue, 19 Jan 2021 08:01:09 -0800 (PST) Received: from [10.137.0.20] (ip-86-49-253-127.net.upcbroadband.cz. [86.49.253.127]) by smtp.gmail.com with ESMTPSA id b17sm2651828ejj.83.2021.01.19.08.01.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 19 Jan 2021 08:01:08 -0800 (PST) Subject: Re: POC: postgres_fdw insert batching To: Amit Langote , "tsunakawa.takay@fujitsu.com" Cc: "Andrey V. Lepikhov" , Tomas Vondra , "pgsql-hackers@postgresql.org" References: <20200628151002.7x5laxwpgvkyiu3q@development> <70d5f38f-1271-234e-c154-3c5c81b5bcf2@enterprisedb.com> <16fcfd4c-2d5e-67f7-fa69-9b5d119bac52@enterprisedb.com> From: Tomas Vondra Message-ID: <9d94c863-ce7c-ea7f-6b84-834c98929e2f@enterprisedb.com> Date: Tue, 19 Jan 2021 17:01:05 +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: Content-Type: text/plain; charset=utf-8; format=flowed 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 1/19/21 7:23 AM, Amit Langote wrote: > On Tue, Jan 19, 2021 at 2:06 PM tsunakawa.takay@fujitsu.com > wrote: >> From: Amit Langote >>> I apologize in advance for being maybe overly pedantic, but I noticed >>> that, in ExecInitModifyTable(), you decided to place the call outside >>> the loop that goes over resultRelations (shown below), although my >>> intent was to ask to place it next to the BeginForeignModify() in that >>> loop. >> >> Actually, I tried to do it (adding the GetModifyBatchSize() call after BeginForeignModify()), but it failed. Because postgresfdwGetModifyBatchSize() wants to know if RETURNING is specified, and ResultRelInfo->projectReturning is created after the above part. Considering the context where GetModifyBatchSize() implementations may want to know the environment, I placed the call as late as possible in the initialization phase. As for the future(?) multi-target DML statements, I think we can change this together with other many(?) parts that assume a single target table. > > Okay, sometime later then. > > I wasn't sure if bringing it up here would be appropriate, but there's > a patch by me to refactor ModfiyTable result relation allocation that > will have to remember to move this code along to an appropriate place > [1]. Thanks for the tip about the dependency on how RETURNING is > handled. I will remember it when rebasing my patch over this. > Thanks. The last version (v12) should be addressing all the comments and seems fine to me, so barring objections I'll get that pushed shortly. One thing that seems a bit annoying is that with the partitioned table the explain (verbose) looks like this: QUERY PLAN ----------------------------------------------------- Insert on public.batch_table -> Function Scan on pg_catalog.generate_series i Output: i.i Function Call: generate_series(1, 66) (4 rows) That is, there's no information about the batch size :-( But AFAICS that's due to how explain shows (or rather does not) partitions in this type of plan. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company