pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ed Kurowski <ed.kurowski@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: Full JSONb column returned over FDW when only single value needed
Date: Fri, 02 Sep 2016 15:06:58 -0400
Message-ID: <26735.1472843218@sss.pgh.pa.us> (raw)
In-Reply-To: <CANo=kM9y24vPyO=ww1aWVnD7Nc8QmZpgMW4pTN=g1g_wvZs4mw@mail.gmail.com>
References: <CANo=kM9y24vPyO=ww1aWVnD7Nc8QmZpgMW4pTN=g1g_wvZs4mw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Ed Kurowski <ed.kurowski@gmail.com> 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



view thread (3+ messages)  latest in thread

Message-ID: <26735.1472843218@sss.pgh.pa.us>
Permalink:  ../26735.1472843218@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/26735.1472843218@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, ed.kurowski@gmail.com
  Subject: Re: Full JSONb column returned over FDW when only single value needed
  In-Reply-To: <26735.1472843218@sss.pgh.pa.us>
  References: <CANo=kM9y24vPyO=ww1aWVnD7Nc8QmZpgMW4pTN=g1g_wvZs4mw@mail.gmail.com> <26735.1472843218@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox