On Fri, Oct 08, 2021 at 10:24:33AM -0700, Lily Liu wrote:
> 1) Remove DISTINCT
>
> A simple example is SELECT DISTINCT(name) FROM R. If there is a unique
> constraint on the name column. The DISTINCT keyword can be removed safely.
> Query plans without the DISTINCT keyword might be much cheaper since
> DISTINCT is expensive.
There's an ongoing discussion and patches for this here.
Erase the distinctClause if the result is unique by definition
https://commitfest.postgresql.org/35/2433/
Perhaps you could help to test or review the patch ?
--
Justin