Re: New hook after raw parsing, before analyze - Mailing list pgsql-hackers

From Tom Lane
Subject Re: New hook after raw parsing, before analyze
Date
Msg-id 19329.1392322937@sss.pgh.pa.us
Whole thread Raw
In response to New hook after raw parsing, before analyze  (David Beck <dbeck@starschema.net>)
Responses Re: New hook after raw parsing, before analyze  (David Beck <dbeck@starschema.net>)
List pgsql-hackers
David Beck <dbeck@starschema.net> writes:
> I have table like data structures in the source system for the FDW I work on.
> These tables are sometimes too big and the source system is able to filter and join them with limitations, thus it is
notoptimal to transfer the data to Postgres.
 
> At the same time I want the users to think in terms of the original tables.

> The idea is to rewrite the SQL queries like this:

>   “SELECT * FROM tableA a, tableB b WHERE a.id=b.id AND a.col1=1234 AND b.col2=987”

> to:

>   “SELECT * FROM fdw_tableA_tableB ab WHERE ab.col1=1234 AND ab.col2=987”

TBH this sounds like a spectacularly bad idea, especially in the place and
way you propose to do it.  You can't even do catalog access safely where
you've put that hook, not to mention that there are many other places
where queries can be submitted.  But more generally, an FDW should not
operate in the way you're describing.

We do lack support for pushing joins to the foreign server, and that needs
to be addressed; but we need to do it in the planner, not by kluging the
query somewhere upstream of that.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Greg Stark
Date:
Subject: Re: Recovery inconsistencies, standby much larger than primary
Next
From: Bruce Momjian
Date:
Subject: Re: Auto-tuning work_mem and maintenance_work_mem