Skip site navigation (1) Skip section navigation (2)

Re: Arguments to foreign tables?

From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Arguments to foreign tables?
Date: 2012-11-06 08:35:35
Message-ID: CA+U5nMLb-kE_4WPr3NWqJDF4A2P=NEhPi8nZ7O2CXEKEAfFNnQ@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
On 6 November 2012 06:09, Jeff Davis <pgsql(at)j-davis(dot)com> wrote:
> On Sun, 2012-11-04 at 15:13 -0500, Tom Lane wrote:
>> Jeff Davis <pgsql(at)j-davis(dot)com> writes:
>> > Is there any fundamental or philosophical reason why a foreign table
>> > can't accept arguments?
>>
>> That isn't a table; it's some sort of function.  Now that we have
>> LATERAL, there is no good reason to contort SQL's syntax and semantics
>> in the direction you suggest.
>
> Maybe I should rephrase this as a problem with SRFs: you don't get to
> define the init/exec/end executor functions, and you don't get access to
> the optimizer information.
>
> It seems like foreign tables are a better mechanism (except for the
> simple cases where you don't care about the details), and the only thing
> an SRF can do that a foreign table can't is accept arguments. So, I
> thought maybe it would make more sense to combine the mechanisms
> somehow.
>
> Take something as simple as generate_series: right now, it materializes
> the entire thing if it's in the FROM clause, but it wouldn't need to if
> it could use the foreign table mechanism.

This seems a useful thought to me.

Tom is complaining about conflating the two features, which does seem
unnecessary. But we can still merge code.

Providing run-time parameters or table-level options to Foreign Scans
seems sensible. I can see why you'd want to pass through parameters
like "work_mem" to the foreign scan and yet not have those as
permanent table options.

(On another thought: why do Foreign Scans get to avoid the
materialization we hate with SRFs?)

-- 
 Simon Riggs                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


In response to

Responses

pgsql-hackers by date

Next:From: Dimitri FontaineDate: 2012-11-06 08:39:22
Subject: Re: Arguments to foreign tables?
Previous:From: Ronan DunklauDate: 2012-11-06 08:19:03
Subject: Re: Arguments to foreign tables?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group