While working on a different FDW, I discovered that postgres_fdw doesn't push a 
DISTINCT clause to the foreign server, unless it's part of an aggregate 
function:

k=# explain verbose select distinct i from tf;
                                QUERY PLAN                                
--------------------------------------------------------------------------
 HashAggregate  (cost=193.20..195.20 rows=200 width=8)
   Output: i
   Group Key: tf.i
   ->  Foreign Scan on public.tf  (cost=100.00..186.80 rows=2560 width=8)
         Output: i, f
         Remote SQL: SELECT i FROM public.tf
(6 rows)

Of course, the same effect can be achieved with GROUP BY, but I'm curious why 
it doesn't push it down?

Reply via email to