postgres_fdw does not push down DISTINCT

From: Christophe Pettus <xof(at)thebuild(dot)com>
To: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: postgres_fdw does not push down DISTINCT
Date: 2022-12-16 04:29:10
Message-ID: 9EE5AAB4-36FC-4FF0-9B0E-CF7B5221D8D1@thebuild.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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?

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2022-12-16 17:08:42 Re: Test if a database has any privilege granted to public
Previous Message Bryn Llewellyn 2022-12-16 00:17:21 Re: Test if a database has any privilege granted to public