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 1mSJBj-0007FM-AS for pgsql-general@arkaria.postgresql.org; Mon, 20 Sep 2021 13:18:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mSJBh-0001rX-R1 for pgsql-general@arkaria.postgresql.org; Mon, 20 Sep 2021 13:18:25 +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 1mSJBh-0001rP-I2 for pgsql-general@lists.postgresql.org; Mon, 20 Sep 2021 13:18:25 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mSJBf-0005X8-27 for pgsql-general@postgresql.org; Mon, 20 Sep 2021 13:18:24 +0000 Received: by mail-wr1-x42b.google.com with SMTP id i23so29657558wrb.2 for ; Mon, 20 Sep 2021 06:18:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=fQQW8J661BXxfPf96RDXOjTshcOtUoPykdpbZmytJnk=; b=pc4vk6C8ZX/2gO0sh/t/RfDVW3JtXWgTO0crrs8VlhWiux8XJaFI/OQpU8ZtbeYx5w SIKFH8gfCd6Za2lGTmDR/FYEjk0TNoF3O02QGeVj3WSZ6bJ0eY8vZ6TzLsWOWk5rWna0 eIU83/+OCU5k/+fgfq2mbJgKorjAoXG1CTGztbaCe4aYNR0Hz7GRlYFGABxAICNkI1ge M3GVKG42pbImFCZsJZ+Tzu7wOxKETAtQIqPX3bCAnkAjoyFQyQS4zX2RtN2mRohD7qsR /x5xOKjsApaQ4up8gYtrb5MKB6iGTXok5a5nI1e8nG11wc9ehiXXOvg8cpCxwORwpL3+ 036w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=fQQW8J661BXxfPf96RDXOjTshcOtUoPykdpbZmytJnk=; b=OfTki+eK+Qmx1k8TB75xgynD0/PnW9Spb5Iy5iI6b8+ZvKQTGLdsonELei6j3ZhEGT 0fgVWvq/GANblxYmXXZQeGS1LjyF6GAzTanrnEDEffv0gf0TQzUtg9ZPfLsrZW7ljWEt 1vuRFm4sw+tFRLhMn179rLO9S7pMx0jcZ/KSpgv7CWHp9OsrIv03AkOmcBA7qufzkFe+ 4orArXIvr99fa4RDs9L9OlqiLAwP4YFYxuY+icen/ZU4WI2cSsWvE2eWpB0RV0MexjhB lyItTsfEGPGjh1+Kais+pSV4HjpL6f1ZZT9wpoAd8DHhTRYLk/ClWb39d6Zu6wolgEJ4 XWnQ== X-Gm-Message-State: AOAM531fDZFms8rUIfy36FoB3+cPka+s1XS8c6f9UFIAvahB3HMrAqdw 4vyEDb+o9uUOsoAYA93nFguLPg== X-Google-Smtp-Source: ABdhPJyCgC7ut4QWv+JfoOZMJZw7wXoGISWd+NE0SeOL0NBe3Wqy3LHgoAJzZ+BQNU8eRWY2AcHwkA== X-Received: by 2002:a05:6000:105:: with SMTP id o5mr28255020wrx.413.1632143899165; Mon, 20 Sep 2021 06:18:19 -0700 (PDT) Received: from localhost.localdomain ([88.116.133.170]) by smtp.gmail.com with ESMTPSA id u6sm18931094wrp.0.2021.09.20.06.18.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Sep 2021 06:18:18 -0700 (PDT) Message-ID: <4c3b032cbde95f53a40ffdcfd1e216309153f43b.camel@cybertec.at> Subject: Re: Possibilities for optimizing inserts across oracle_fdw foreign data wrapper From: Laurenz Albe To: Niels Jespersen , "pgsql-general@postgresql.org" Date: Mon, 20 Sep 2021 15:18:17 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.40.4 (3.40.4-1.fc34) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sun, 2021-09-19 at 10:28 +0000, Niels Jespersen wrote: > We are often using the oracle_fdw to transfer data between Postgres (version 11+) and Oracle (version 18+). It works great. >   > However I have a task at hand that requires inserting a few billion rows in an Oracle table from a Postgres query. >   > insert into t_ora (a,b,c)    > select a,b,c from t_pg; >   > This is driven from a plpgsql stored procedure, if that matters. >   > I want to optimize the running time of this. But I am unsure of which, if any, possibilities there actually is. >   > Reducing the number of network roundtrips is usually a good way to increase throughput. But, how do I do that? >   > If I could make the Oracle insert direct load, that would usually also increase throughput. > But, is that possible here. There are no constraints defined on the destinaton tables. The cause of the bad performance for bulk data modifications is that the FDW API is built that way: each row INSERTed means a round trip between PostgreSQL and Oracle. That could be improved by collecting rows and inserting them in bulk on the Oracle side, but I don't feel like implementing that and complicating the code.