Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bftnx-0000Ll-HC for pgsql-bugs@arkaria.postgresql.org; Fri, 02 Sep 2016 19:07:09 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bftnw-0001c4-SN for pgsql-bugs@arkaria.postgresql.org; Fri, 02 Sep 2016 19:07:08 +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_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bftnw-0001ba-2R for pgsql-bugs@postgresql.org; Fri, 02 Sep 2016 19:07:08 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bftnp-00049L-4u for pgsql-bugs@postgresql.org; Fri, 02 Sep 2016 19:07:07 +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 u82J6wSN026736; Fri, 2 Sep 2016 15:06:58 -0400 From: Tom Lane To: Ed Kurowski cc: pgsql-bugs@postgresql.org Subject: Re: Full JSONb column returned over FDW when only single value needed In-reply-to: References: Comments: In-reply-to Ed Kurowski message dated "Fri, 02 Sep 2016 18:18:34 -0000" Date: Fri, 02 Sep 2016 15:06:58 -0400 Message-ID: <26735.1472843218@sss.pgh.pa.us> X-Pg-Spam-Score: -3.4 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Ed Kurowski writes: > This runs very quickly directly on the remote postgres server (indexes have > been set appropriately on the foreign server), but is slow when running > over the fdw. I believe I have tracked this down to the fact that it is > returning the entire data column (which is jsonb, and sometimes large) > instead of the single field from the json my query cares about. > Is there anyway to stop postgres from returning the entire jsonb column? This isn't a consideration that postgres_fdw knows anything about at the moment. You could force it by defining a view on the remote server that only exposes data->>'query' rather than the whole data column, and making the foreign table reference the view not the underlying table. Of course that approach won't scale if there are a lot of different jsonb fields you may want to ask about. FWIW, I'm a little suspicious of whether it'd really help that much, though an experiment with the view approach would probably prove or disprove things quickly. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs