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 1khyFu-0008Qp-Ql for pgsql-general@arkaria.postgresql.org; Wed, 25 Nov 2020 17:06:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1khyFt-0001HT-Q4 for pgsql-general@arkaria.postgresql.org; Wed, 25 Nov 2020 17:06:57 +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 1khyFt-0001HM-HM for pgsql-general@lists.postgresql.org; Wed, 25 Nov 2020 17:06:57 +0000 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1khyFr-0006MN-6r for pgsql-general@lists.postgresql.org; Wed, 25 Nov 2020 17:06:56 +0000 Received: by mail-lf1-x129.google.com with SMTP id d20so4101646lfe.11 for ; Wed, 25 Nov 2020 09:06:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=duneanalytics-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:organization:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=W2iZ+BNPmwRFhiRs4An55VOxDIapixGShEhjkpKf+k4=; b=MD/fy+mi1OF/HSvH27Abw/2xfyZptILmNEFOErAu8iMh3doq8QdjyuKeCmsOpRkyz+ 2RPYMmSGgFQRhNcjAiVwAdFVn2SeJ6IiEaoo0GH4hxRcRRIiWqTJ5J8RfOY+GWqJ/+px DqOCyStjhqn7+XSltF2x4GrV9wOCkHKgUIEW7pyDuUI8IDWfhO47wcuW+Gp9Z9+w4MgB lBIWn5KQx7HqmPfsqilS71MmbjEEgPBWcUBKNhCP12pIZsZLVRyfqmUfteD1zhYa7rhs wj/J2omewb+yxwhxhlIYtqAFEuclDyBeDUvy03VmtparOQYYcPffp3yg5YRIXD+JYqro VWqw== 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:organization :message-id:date:user-agent:mime-version:in-reply-to :content-transfer-encoding:content-language; bh=W2iZ+BNPmwRFhiRs4An55VOxDIapixGShEhjkpKf+k4=; b=Ipi6/ySfJv2xg+RmIEw73XO8HA9EI7TSCAh0tXaf5wn6Aa8aeHDknHPpH2Tx3Vhbwg +4Awh1KJDe3wH/vCsZe/5gUZLplKTW5TEvd9bF+GLyj4fglzfxxWXW6fXoC200TtmGv7 Rh7QwG3INb9oPdzDAqcLc/6oZVla07tfTVw+vls/6TiZnl9T4oBgLJQvjFeGstI+y6CK sw8y1hw8YsdUdDJWmt3WF4DWuoBq2eJm98cB8Ip3LC/dxWZS0f26Txgj1iP//xVEaCQq W8m4mnoYIIq1rGKLKM+2v37o1IYFG7qBBx0fS0HAF2M+xUf6YTcKIs0+EYehX2tN3Vxf +DJw== X-Gm-Message-State: AOAM530BChfqLWvugZa4EJBOamdCsQe3r3Su8UZu545CqDqFWpnD+Org Jn5DCFWz7tj9QxBwlgVa9tLsog== X-Google-Smtp-Source: ABdhPJy8y+VDeMbzV1DIaSY7Hl6RUmFmoT4bWV7VX1sndNYrwqZltPkIoZGdJNjU03FKwkoxbgUVPA== X-Received: by 2002:a19:df54:: with SMTP id q20mr1932977lfj.300.1606324013544; Wed, 25 Nov 2020 09:06:53 -0800 (PST) Received: from [192.168.1.149] (host-37-191-231-244.lynet.no. [37.191.231.244]) by smtp.gmail.com with ESMTPSA id m7sm326575lfj.113.2020.11.25.09.06.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 Nov 2020 09:06:52 -0800 (PST) Subject: Re: postgres_fdw insert extremely slow To: Tom Lane Cc: Adrian Klaver , pgsql-general@lists.postgresql.org, wilhelm@duneanalytics.com References: <3862aa4d-01c7-c76b-4497-ebce1af702cc@aklaver.com> <10df210c-a1bb-f909-9a48-61ac54880df0@duneanalytics.com> <493978.1606323509@sss.pgh.pa.us> From: Mats Julian Olsen Organization: Dune Analytics Message-ID: Date: Wed, 25 Nov 2020 18:06:52 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.2 MIME-Version: 1.0 In-Reply-To: <493978.1606323509@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 25.11.2020 17:58, Tom Lane wrote: > Mats Julian Olsen writes: >>> Postgres version(s)? >> x: Aurora PostgreSQL 11.7 on x86_64-pc-linux-gnu, compiled by gcc (GCC) >> 4.9.3, 64-bit (RDS) >> y: PostgreSQL 12.2 (Ubuntu 12.2-2.pgdg19.10+1) on x86_64-pc-linux-gnu, >> compiled by gcc (Ubuntu 9.2.1-9ubuntu2) 9.2.1 20191008, 64-bit (GCP) > Hmm, I wonder if Aurora could be doing something funny here? > > Anyway, to answer your question, no that's not the expected level of > performance. postgres_fdw is certainly not inexpensive compared to > local table access, but I'd still think inserts should take only a > small number of milliseconds. It seems like something must be > blocking the query. Have you tried looking into pg_locks on the > remote server while this query is running? > > regards, tom lane Thanks Tom, I'll try to spin up a regular Postgres instance on both rds and ec2 and see if that helps. As for the locks, I can not see any blocked activity on the remote server while the query runs. -- Mats CTO @ Dune Analytics We're hiring: https://careers.duneanalytics.com