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 1l5Uwr-0003lH-KK for pgsql-general@arkaria.postgresql.org; Fri, 29 Jan 2021 14:40:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l5Uwo-0005GR-G9 for pgsql-general@arkaria.postgresql.org; Fri, 29 Jan 2021 14:40:30 +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 1l5Uwo-0005GK-6q for pgsql-general@lists.postgresql.org; Fri, 29 Jan 2021 14:40:30 +0000 Received: from mout.gmx.net ([212.227.17.22]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l5Uwj-00062P-Tz for pgsql-general@lists.postgresql.org; Fri, 29 Jan 2021 14:40:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1611931223; bh=ZNi+3xRDi2fIDX+F9TuKxzATKMEIaBSAzS0WFYa+WSc=; h=X-UI-Sender-Class:Subject:To:References:From:Date:In-Reply-To; b=OeKRJ+AY4WhM/Kl6ao78e/9seGiCvwwzEfhDN6DDytI1qagyqjOIZagnm3M/p2q/O z9Ati9d+qECblCvD3UEpevru5bwSQYsWU8R3js0Spd7OKxLMnyc3q+ZKlW5M/7c1Hm fd+AHGGe5seXCZEQw4sHPejNcGvjLGww9hFHrYxY= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [10.1.32.133] ([185.40.248.10]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1McH5Q-1lfvA23hCG-00ciqf for ; Fri, 29 Jan 2021 15:40:22 +0100 Subject: Re: Foreign table performance issue / PostgreSQK vs. ORACLE To: pgsql-general@lists.postgresql.org References: From: Thomas Kellerer Message-ID: <7289a882-66eb-c0d4-dc7a-c6ab16eb0201@gmx.net> Date: Fri, 29 Jan 2021 15:40:21 +0100 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:0APgNAEkTOfVB6GD7xpdpHtWnkJuaUVmORg0MSBoupvbVmSoRJH TkRTWCZRLsYfUgpUdwfDbQQg7cpsYLXQHpu5QYTjCdNRosAvwf7rzl51jVDyfeaGXeoswVL /5OQoa10g/swHklXvoGQAKGyk3jrz7KOpdyt9rfDHX9K+TJeWu7L9QpL2Z7Jj8e84/COSX+ Fxnd/DD6DHT6qcxBFkfGw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:OHkWGT+1Jcw=:89LcUeQShJdV5mNjuysV59 HO/W8KafgjAbXuvAb1jE/pRIOyXwjy2/TKVl4TWc57UgzOZbA5gkMMpvI3Fr11U2pEO5U+xRV 27P8H35FIeSrdwbnRcvre/R8jjyCogdxe7p1PGreTvSiu7cFz1vykqnKkxxTWmqjXM41fw72x cnB440aYSCXP59C6rh4maL9/vJEGpSVeY743oE7oqKAAuZP3rUn0FN+WCVo90R7xJSyhCrdho f+yfg88ixRK8QfvFznURVRS9FfsffmOOZb4a5dqCe7oI8i1JkoGY9vAkRVkWGOQQRAqRE3jSa F5rsKpZDznJ2Dp/9yIIEjUUDXqY3ZmFoHpzMJuoIh7zrhUn5bfRWTGY79+fk2Ai+9hVbkmq6E e0BfWSJJPbfsYrbJW+ZBg8ytvSyNHMMr5Cv4MRnLlBtpobwvtCZYFqx4P7q649OVmDsStABUW JbXP8nlSeyqm0A05j0sIg9S9BS7zd4kdwCRu32v0K+g/nTNVAGQ2usyq+wXCqFkH8CrLUBt22 1PYNZbkX4JhqvgDGgSqRQzVV/2aMub0QxXjeT/wo0Mw2JfbrSGJ/VVPopB8Ov/IP9IsV+utjC zV2yVNT0kxTPkKrzzGvqJ495uNcW9IPLWJl+K7F2uNvgPyh3f2pvMHUI4Ed4oKKHmImEou53f lrLz+0GBrNmtnpZKSu/QuGoDmquGRZPUsAF6EifkhrbenRSkD9+zhQGG9Rz/jWnJWN58n2f6v PZPhJQ7p/QRe+gB9hmhXBqDSII/GMrA/y4QxgPOk7HVzmW5YDqrEETAqMzlAm80L0Bu00PCNB wBYoDgMPAgiOimFcjfWplLdqczOoUh3ulfQXJ8VQ5rNmbh/ACXZ/Eb8S5/VFqwOC73Xb+3cbI 07PMk6tSw5I+CvaWUhNA== List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Markhof, Ingolf schrieb am 29.01.2021 um 13:56: > The set-up basically is a production database and a reporting > database. As names indicate, the production database is used for > production, the reporting database is for analysis. On the reporting > database, the only way to access product data is via foreign tables > that link to the related production tables.> > =C2=A0 > However, the same set-up worked fine in Oracle before. Reporting > wasn't always fast, but it delivered results in acceptable time. A > query executed on the Oracle reporting server returns data in e.g. 30 > seconds. But running the query translated to PostgreSQL on the > PostgreSQL DB does not deliver a single row after hours (!) of run > time. > > So, I wonder: Is there a fundamental difference between Oracle > database links and foreign tables in PostgreSQL that could explain > the different run times? My guess is, that your queries use predicates that can't be pushed down to the foreign server on Postgres, but Oracle can. What is your Postgres version? If my assumption is correct, then maybe if you showed one example query, it might be possible to figure out a way to restructure it. Is logical replication an option? How accurate does the data on the reporting server need to be? Would using materialized views that "cache" the foreign table be an option? That's obviously only suitable if you can live with some stale data and are fine with refreshing them maybe twice a day (depending on how fast the refresh is)