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 1lBgr2-0006T9-Cn for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Feb 2021 16:36:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lBgr1-0003YI-8m for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Feb 2021 16:36:07 +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 1lBgr1-0003Y8-1k for pgsql-hackers@lists.postgresql.org; Mon, 15 Feb 2021 16:36:07 +0000 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lBgqy-0007XV-9G for pgsql-hackers@postgresql.org; Mon, 15 Feb 2021 16:36:06 +0000 Received: by mail-ej1-x62c.google.com with SMTP id jj19so12200062ejc.4 for ; Mon, 15 Feb 2021 08:36:03 -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=MwEaDtDnzU0GbQ7azmZeX448n2x/YhlcW1QUVsh6Fyk=; b=lkVz9u3sGSMJ3sP9Hv0L4YnXy4UlWZ9Qbr5uilm7Baa5RpF+Yag+fKdpLMToWjsnb1 NBJEr95HZyayt4RpJN83FnnttNbGAFYvZpYnrCU8u/6zLC6N4b2FGrMoTfrA20V09tBm grwyDv1567zXR/h+XuAkcKohh8UDaRnXHaUtha++tuxyGhXTbB6fEv2EN7f04H1IcIAF RPcRps21wGk6KwQE+pROyb7Z6nHx5yvYp16RvyKkjfjG/fGLgZUIxDgtl4zHOnBZ05Yw YOW1pWa0pYYpWR9YuSs2RKzLwreRqqnmMLlL6TfKh3wNVV7c/CxleMT7sLaUWsCW31bn sLaA== 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=MwEaDtDnzU0GbQ7azmZeX448n2x/YhlcW1QUVsh6Fyk=; b=bPHqX30nYIdMoOmENtw7E0pWbZ8ge16NxlsZHnvkhk3gwKXL1peULyVlyaJzAzYybk Yvj+LgUIOUz4lJ1rOE5fKHu+gN28KFN+REej2jp48N4CtFnr34sWqfe4JgVEsvFL7PVa nCA1B4BeQ+VneagAOgvtkp2MDFKDrxwLrJPKg4OK0bAM4Q8ugrla+9nOQe6EbxQy5KJO gysFzqc8JXfHva059Up3/KGBJ3D/VpKalOeXvHeu0qFiF3hFD65ZXuhs/UjAqNh+b9PL pOHP9D7SOMrfIGbUUjjYEUGOQW6dmDaGJockHv+rJvVN2rulmydOhXQWPaSi49maVkIj +/og== X-Gm-Message-State: AOAM530zXi17L3nEIOZs4LzYUsCO8p6O0j9OOhl/z7BIOlrmP/46yFxG mGRRWxVTQh8nc27bFmCfCT3v8Oi0dEt4NXjAvrfPdcTLTz+OPNLUm45VXaoxgAmiAXkqRhZDhRS FigI+2UfTQwamEu7VLCrH4CxWPuVxa0YdqW89D2O4goI+QAfLZieknuPfx+VP9jSR9W739Kd9AM 11sdRZhqW5hBuxxiF5scLvJDNfPkbYUbKZt89xMgU9neRGre/V0+BKjdd0WaqYRKEclrjwfXQpW l+evFw3zTuEJpvE4pwj3rniFOZDU6KjKJeC5g== X-Google-Smtp-Source: ABdhPJxQ9qtBFtXblO0ACkEt5jBEwU7XlHz/xql/nim4HGxXKphnu+0IKtZVFi9LMZZ4D9YBXw6IkA== X-Received: by 2002:a17:906:ccd8:: with SMTP id ot24mr11393905ejb.46.1613406963134; Mon, 15 Feb 2021 08:36:03 -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 f1sm10948075ejt.21.2021.02.15.08.36.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 15 Feb 2021 08:36:02 -0800 (PST) Subject: Re: POC: postgres_fdw insert batching To: Amit Langote , "tsunakawa.takay@fujitsu.com" Cc: Zhihong Yu , "Andrey V. Lepikhov" , Tomas Vondra , "pgsql-hackers@postgresql.org" References: <20200628151002.7x5laxwpgvkyiu3q@development> <3ca9496f-0827-bf21-b709-593de63440a5@enterprisedb.com> <4faa3d09-0fc8-c4d6-7aec-87428fabd161@enterprisedb.com> <0fc809f6-7c3c-6d06-7ea3-f10765dfdf08@enterprisedb.com> <067ddf09-225c-e3c5-ea47-4dd39b34ebb0@enterprisedb.com> From: Tomas Vondra Message-ID: <7ffcee1f-d55e-cbdf-5f3f-98f1c30537ef@enterprisedb.com> Date: Mon, 15 Feb 2021 17:36:00 +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 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/5/21 3:52 AM, Amit Langote wrote: > Tsunakwa-san, > > On Mon, Jan 25, 2021 at 1:21 PM tsunakawa.takay@fujitsu.com > wrote: >> From: Amit Langote >>> Yes, it can be simplified by using a local join to prevent the update of the foreign >>> partition from being pushed to the remote server, for which my example in the >>> previous email used a local trigger. Note that the update of the foreign >>> partition to be done locally is a prerequisite for this bug to occur. >> >> Thank you, I was aware that UPDATE calls ExecInsert() but forgot about it partway. Good catch (and my bad miss.) > > It appears I had missed your reply, sorry. > >> + PgFdwModifyState *fmstate = resultRelInfo->ri_FdwState ? >> + (PgFdwModifyState *) resultRelInfo->ri_FdwState : >> + NULL; >> >> This can be written as: >> >> + PgFdwModifyState *fmstate = (PgFdwModifyState *) resultRelInfo->ri_FdwState; > > Facepalm, yes. > > Patch updated. Thanks for the review. > Thanks for the patch, it seems fine to me. I wonder it the commit message needs some tweaks, though. At the moment it says: Prevent FDW insert batching during cross-partition updates but what the patch seems to be doing is simply initializing the info only for CMD_INSERT operations. Which does the trick, but it affects everything, i.e. all updates, no? Not just cross-partition updates. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company