suppose I have a query like
select * from remote_table
join local_table using(common_key)
where remote_table is a FOREIGN TABLE
with postgres_fdw
and local_table
is a regular table.
local_table
is small (100 rows) and remote_table
is large (millions of rows).
It looks like the remote table is pulled in its entirety and joined locally, when it would be more efficient to ship the smaller table to the remote server and join remotely.
Is there a way to get postgres_fdw to do that?
WITH cte AS (SELECT common_key FROM local_table) SELECT * FROM remote_table WHERE common_key IN (TABLE cte);
On second though: I doubt that can fly ... – Poussin