Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gMwwM-0005HB-Cu for pgsql-bugs@arkaria.postgresql.org; Wed, 14 Nov 2018 15:18:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gMwwK-00067z-M9 for pgsql-bugs@arkaria.postgresql.org; Wed, 14 Nov 2018 15:18:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gMwwK-000647-FF for pgsql-bugs@lists.postgresql.org; Wed, 14 Nov 2018 15:18:48 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gMwwH-0003JY-VY for pgsql-bugs@lists.postgresql.org; Wed, 14 Nov 2018 15:18:48 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id wAEFIg0C007372; Wed, 14 Nov 2018 10:18:42 -0500 From: Tom Lane To: timur.luchkin@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15506: Foreign data wrapper (postgres_fdw) unexpected behavior In-reply-to: <15506-9c8798a2d6cd06b0@postgresql.org> References: <15506-9c8798a2d6cd06b0@postgresql.org> Comments: In-reply-to =?utf-8?q?PG_Bug_reporting_form?= message dated "Wed, 14 Nov 2018 09:44:42 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <7370.1542208722.1@sss.pgh.pa.us> Date: Wed, 14 Nov 2018 10:18:42 -0500 Message-ID: <7371.1542208722@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk =?utf-8?q?PG_Bug_reporting_form?= writes: > When I trying to analyze the foreign table itself , - it takes all the > incoming network traffic (400Mbit) and can't complete in 10 minutes (I can't > wait more, because it affects production environment). > Why the analyze of the foreign table can't just take already collected > statistics from the remote server? Is it a bug or some limitation? This is not a bug; it's operating as designed. The key reason not to do it as you suggest is that whatever stats the remote server might have for its table don't necessarily apply to the foreign table, because the foreign table is in effect a view of the remote table --- it could, for example, have different column types necessitating different stats. Or the remote server could be a different PG version that doesn't even collect the same stats. Another point is that ANALYZE is supposed to produce up-to-date stats, but the remote server might not have up-to-date stats. It's interesting to speculate about getting around that by asking the remote server to do an ANALYZE, but we can't assume that the local user has permissions to do that. There's been some discussion of providing facilities for dumping and loading statistics, which was mainly thinking about improving pg_upgrade but could also offer you a slightly-tedious solution for this situation. It hasn't got past the arm-waving stage yet though. regards, tom lane