From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | David Gudeman <dave(dot)gudeman(at)gmail(dot)com> |
Cc: | Postgres <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: minimizing the target list for foreign data wrappers |
Date: | 2013-04-25 16:24:12 |
Message-ID: | 5127.1366907052@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
David Gudeman <dave(dot)gudeman(at)gmail(dot)com> writes:
> One of the problems I'm having is that in my application, the foreign
> tables typically have hundreds of columns while typical queries only access
> a dozen or so (the foreign server is a columnar SQL database). Furthermore,
> there is no size optimization for NULL values passed back from the foreign
> server, so if I return all of the columns from the table --even as NULLs--
> the returned data size will be several times the size that it needs to be.
> My application cannot tolerate this level of inefficiency, so I need to
> return minimal columns from the foreign table.
That's already possible; see contrib/postgres_fdw in HEAD for an
existence proof.
> The documentation doesn't say how to do this, but looking at the code I
> think it is possible. In GetForeignPlan() you have to pass on the tlist
> argument, which I presume means that the query plan will use the tlist that
> I pass in, right? If so, then it should be possible for me to write a
> function that takes tlist and baserel->reltargetlist and return a version
> of tlist that knows which foreign-table columns are actually used, and
> replaces the rest with a NULL constant.
You do not get to editorialize on the tlist that will be computed by the
ForeignScan node: in the case of a simple single-table SELECT, that's
going to be computing the expressions the user asked for. Nor can you
alter the expectation about the rowtype of the scan tuple that's
returned by the FDW: that needs to match the declared rowtype of the
foreign table. However, you can skip fetching unneeded columns and just
set those fields of the scan tuple to nulls. That's cheap enough
(particularly if the scan tuple stays virtual) that I'm unconvinced we
should contort the APIs to the extent that would be needed to let the
FDW change the scan tuple rowtype dynamically.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2013-04-25 17:17:31 | Re: [ADMIN] Simultaneous index creates on different schemas cause deadlock? |
Previous Message | Andrew Dunstan | 2013-04-25 16:14:13 | Re: danger of stats_temp_directory = /dev/shm |