Re: FDW / list of needed columns, WHERE conditions (in PlanForeignScan)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tomas Vondra <tv(at)fuzzy(dot)cz>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: FDW / list of needed columns, WHERE conditions (in PlanForeignScan)
Date: 2012-05-28 21:20:37
Message-ID: 13762.1338240037@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tomas Vondra <tv(at)fuzzy(dot)cz> writes:
> I'm writing my first FDW, and I need to get the list of columns I
> actually need to fetch when planning the query. I do want to fetch only
> the columns that are actually needed, not all of them.

reltargetlist and attr_needed only tell you about columns the scan has
to *output* (ie, they are used in join conditions or the final result).
Vars that are only mentioned in baserestrict conditions aren't
included. So you'd need to do something like pull_varattnos on the
baserestrictinfo list and union that with attr_needed.

> Also, I'd like to apply as much restrictions as possible when executing
> the plan. I see there's PlanState->qual, described as "implicitly-ANDed
> qual conditions", which I assume is what I need. But this seems to be
> available only in BeginForeignScan (as ss.ps.qual in ForeignScanState),
> not in planning which is the place where I need to compute estimates
> etc. Where do I get this, when planning the query?

Same answer, rel->baserestrictinfo.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Janes 2012-05-28 21:24:26 Re: pg_dump and thousands of schemas
Previous Message Tomas Vondra 2012-05-28 20:46:41 FDW / list of needed columns, WHERE conditions (in PlanForeignScan)