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 1khxr6-0006WR-3C for pgsql-general@arkaria.postgresql.org; Wed, 25 Nov 2020 16:41:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1khxr5-0002VL-1a for pgsql-general@arkaria.postgresql.org; Wed, 25 Nov 2020 16:41:19 +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 1khxr4-0002VE-QR for pgsql-general@lists.postgresql.org; Wed, 25 Nov 2020 16:41:18 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1khxqz-00069v-R5 for pgsql-general@lists.postgresql.org; Wed, 25 Nov 2020 16:41:17 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 7367676A; Wed, 25 Nov 2020 11:41:11 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 25 Nov 2020 11:41:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=+ SpgXdbB8b8qibm+4B8hjvRxaYVjQAi9jCvXS24zEzk=; b=eEJeOwarAFf9a0Ya+ 29wHDCjC4atjnzAzNgpN1FXCU5fvPbOAlE1uLQIPV7/X0E0rKOyRojmF6XZFkUXP EMzHnhQHmopr0h2w9dAIH/ILyrw9oLJGck39BqD1jYXxRlEt8ydvoPgyIzygZuHd krkT+UieQb4pAmiAt3hLVtFlFFuqRXF8otLTtoH2NipehDC2wehBzUJvwuxDgRqF V4Ju/aY/64zIX4UVJnHn3TVuAdfNz0FjLX1Mcb5Q7Urd+vL5sBtMbN9ilJeLetGP OLAkhFJVj2TowShz4LEJbP/tIcO4VEGKodD3Ak64ShpiddK99Q8ETtww++ZHmfp9 iMDYQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=+SpgXdbB8b8qibm+4B8hjvRxaYVjQAi9jCvXS24zE zk=; b=Y+X18WaT6BRd+Tmwds0nwN6VftSHqEoam8tnAXyBdPtph8IwH7H0vqwIp 2ECNDO5CazGjQEBWyVu+79W/EYG7yJjv1XTvzkzDGIyGTbxLWbMmwi5ZRUsJi9FG A4Va5mxJHWuxIMpYzIMNI9bFXmFUXTR+hJbxZqyWUP+FIsQFSkqxmfphHKqkyNgk O+R1HVZGq+XWYZ4rHymRUaCKTKMNimDkKpUf+y+l6IycNsL5VVMx1SO/Yw9PmBg+ 49bRHKcsOdlu1iZbhxBCxuxJpMANzf5pr7oTUfFWwM4bdWD2NogSqavuDZXTVrfM 17z7fZ8KjAIuB2RKtf36CtrqdwlKg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudehtddgleefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthejredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucggtffrrghtthgvrhhnpeelfeehiefffeekueevjedtteegudekudetuefhkefg iedvjeffleetffehgeeugfenucffohhmrghinhepughunhgvrghnrghlhihtihgtshdrtg homhenucfkphepjeehrddujedvrdduledrudefleenucevlhhushhtvghrufhiiigvpedt necurfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrg hvvghrrdgtohhm X-ME-Proxy: Received: from [192.168.1.4] (75-172-19-139.tukw.qwest.net [75.172.19.139]) by mail.messagingengine.com (Postfix) with ESMTPA id 776503064AB4; Wed, 25 Nov 2020 11:41:10 -0500 (EST) Subject: Re: postgres_fdw insert extremely slow To: Mats Julian Olsen , pgsql-general@lists.postgresql.org References: From: Adrian Klaver Message-ID: <3862aa4d-01c7-c76b-4497-ebce1af702cc@aklaver.com> Date: Wed, 25 Nov 2020 08:41:09 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.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 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 11/25/20 8:37 AM, Mats Julian Olsen wrote: > Helle pgsql-general, > > We have just set up postgres_fdw between two postgres databases, x and > y, with the plan to periodically insert data from x into y. > > We've successfully set up the connection with a few options: > `use_remote_estimate 'true'` and `fetch_size '50000'` (the latter we've > played around with). We've run ANALYZE on the foreign server. > > SELECTs against the foreign table returns in milliseconds, however an > INSERT of 100 rows takes 10 seconds. we have roughly 200 000 rows for > the initial sync, which translates into ~6 hours. Postgres version(s)? Without the actual query and EXPLAIN ANALYZE on it this will be difficult to answer with any detail. Also would be nice to have the table schema. > > Is this the expected performance of postgre_fdw? Is there anything we've > overlooked when setting this up? Very curious to hear experiences from > the community when doing read/write and not just read from foreign sources. > > Best regards, > > -- > Mats > CTO @ Dune Analytics > We're hiring: https://careers.duneanalytics.com > -- Adrian Klaver adrian.klaver@aklaver.com