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 1juPaH-0004dF-4s for pgsql-hackers@arkaria.postgresql.org; Sun, 12 Jul 2020 00:11:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1juPaG-00059Z-4O for pgsql-hackers@arkaria.postgresql.org; Sun, 12 Jul 2020 00:11:08 +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 1juPaF-00059R-Nz for pgsql-hackers@lists.postgresql.org; Sun, 12 Jul 2020 00:11:07 +0000 Received: from mail-ej1-x641.google.com ([2a00:1450:4864:20::641]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1juPaD-00018M-Aw for pgsql-hackers@postgresql.org; Sun, 12 Jul 2020 00:11:06 +0000 Received: by mail-ej1-x641.google.com with SMTP id rk21so10298070ejb.2 for ; Sat, 11 Jul 2020 17:11:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=8VtTPqAwiVx/fjmUpvS4H1uvaQLAjeWNpfRfrmoxOzA=; b=myKCmPDU0xJsmxHEa1QpM9ixfTTb83Hcy1z7m+tA/+wbWYHMVp4cZxB/+YMVunL7lQ JgHbeYJJ4duNkem9I/jrs8OhVn4wtmaX4V7wDNE9nTS+9i8dIu4OK4IPeOgb4+hluFn3 2LnbpzrUmh12jnC96K9k/jq+v28kFABXkKOXY8RJH0HIaqUTcUEk4evNVRFs8C1Wj8eh FMa9NGRWQl4RiCUk+HtYRWn9cq9kNdHeBTijUtUL6P2YppQrxLGXUb2aHdTBriMqJ9cM YzIZVDZdrO0KUlD4cgbonVKxEnWZvL2CN/G/nQiOwsMpb+gxkpVFb4FAJ0cr6nb49M8c m3tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=8VtTPqAwiVx/fjmUpvS4H1uvaQLAjeWNpfRfrmoxOzA=; b=HWKAXspff/K6E2ooIXNnE7E89QpAzJe/nfNIxdIfXrO5piqzCi1kaVQ8PF8slDp0dK rJyv/9S6pvM8gsgRLxzIOlmTVmxNEfLsKxBOea/ehuLzrdA92XmQQAyOcaC9fK7ZBXLX MZIsdx9KaBIVuWYIcf1t/lhK9u0y//tSyQRlBpw2ECJB6V1oiiXpA1/PcZk6D5WQd9ev +K+js15Wf3OT01tTQIBtM+b3027vO4zTPAUHQYG6k4h41vjOilA0J4qsYySlZUHnB0ba MQlfhNYLLx4Iqs/p7zPDptXBWu7/vFHYJtS6Ota3Ki2mQUmZrA4POZ94K3AoSjZu+k+b hTbA== X-Gm-Message-State: AOAM532HicBqFmFA8FbU2kVkFHwBy0mhqaTJi0Ep6xYwoZgEiJcA021u QamkXU+ups6dYNb7hEV2i6WTPxGQDnM= X-Google-Smtp-Source: ABdhPJyy+u7lvVd3kZozXO15zuzbROd1KUNyLs5BgEyOSU/RH/ucpw0SFVeH8zwM3TOtWQP4C8MP0Q== X-Received: by 2002:a17:906:6d0e:: with SMTP id m14mr66545267ejr.251.1594512664095; Sat, 11 Jul 2020 17:11:04 -0700 (PDT) Received: from localhost (ip-86-49-253-141.net.upcbroadband.cz. [86.49.253.141]) by smtp.gmail.com with ESMTPSA id l22sm6428416ejr.98.2020.07.11.17.11.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jul 2020 17:11:03 -0700 (PDT) Date: Sun, 12 Jul 2020 02:11:01 +0200 From: Tomas Vondra To: "Andrey V. Lepikhov" Cc: pgsql-hackers@postgresql.org Subject: Re: POC: postgres_fdw insert batching Message-ID: <20200712001101.x65f3hvsanvamtgj@development> References: <20200628151002.7x5laxwpgvkyiu3q@development> <0300d7df-854b-6f72-1e93-dfbf98f3fc8a@postgrespro.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <0300d7df-854b-6f72-1e93-dfbf98f3fc8a@postgrespro.ru> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, Jul 10, 2020 at 09:28:44AM +0500, Andrey V. Lepikhov wrote: >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? > Because I was focused on speeding-up inserts, and that is not using CopyMultiInsertBuffer I think. I agree the way the tuples are stored may be improved, of course. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services