Re: Joins between foreign tables

From: Geoff Montee <geoff(dot)montee(at)gmail(dot)com>
To: Jason Dusek <jason(dot)dusek(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Joins between foreign tables
Date: 2015-06-08 17:40:25
Message-ID: CAA7biFOXnbu9bPY_M1nrB3E_tkMUVba-uvRvikH4sufgAAHSYQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Jun 8, 2015 at 10:29 AM, Jason Dusek <jason(dot)dusek(at)gmail(dot)com> wrote:
> The databases involved are all Postgres 9.4 or 9.3. The FDW is the Postgres
> FDW.
>
> The join node (the one from which queries are issued) is Postgres 9.4
> installed yesterday from the Postgres Apt repository. It's using the version
> of the wrapper that is shipped with that package.
>
> The databases being queried -- the ones with the actual tables -- are both
> Postgres 9.3.5, on Amazon RDS.
>

Sorry, I forgot to include pgsql-general on the address list for my reply.

It seems that postgres_fdw in Postgres 9.3 and 9.4 supports where
clause push-down according to the documentation:

http://www.postgresql.org/docs/9.3/static/postgres-fdw.html

"postgres_fdw attempts to optimize remote queries to reduce the amount
of data transferred from foreign servers. This is done by sending
query WHERE clauses to the remote server for execution, and by not
retrieving table columns that are not needed for the current query. To
reduce the risk of misexecution of queries, WHERE clauses are not sent
to the remote server unless they use only built-in data types,
operators, and functions. Operators and functions in the clauses must
be IMMUTABLE as well."

I'm guessing that postgres_fdw sees that one of your function calls is
IMMUTABLE, so it thinks it is unsafe to push-down. It is probably your
call to NOW(). You might want to try replacing that with a literal
somehow, if you can.

Geoff

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message sym39 2015-06-08 20:43:58 BDR: DDL lock problem with function inside a schema
Previous Message Alvaro Herrera 2015-06-08 17:36:11 Re: [GENERAL] 9.4.1 -> 9.4.2 problem: could not access status of transaction 1