Re: Removing useless DISTINCT clauses - Mailing list pgsql-hackers

From David Rowley
Subject Re: Removing useless DISTINCT clauses
Date
Msg-id CAKJS1f8AnhCdLcXesLGbUUjGx2+QETHLeR7q-KBriuR-Lm8maQ@mail.gmail.com
Whole thread Raw
In response to Re: Removing useless DISTINCT clauses  (Jim Finnerty <jfinnert@amazon.com>)
Responses Re: Removing useless DISTINCT clauses  (Melanie Plageman <melanieplageman@gmail.com>)
List pgsql-hackers
On 24 March 2018 at 01:42, Jim Finnerty <jfinnert@amazon.com> wrote:
> Distinctness can also be preserved across joins, so if you have a 'snowflake
> query' type join, where all the joins are to a unique key, then the
> distinctness of the other side of the join is preserved.  For example, a
> SELECT DISTINCT * FROM fact_table ... that joins from each column in its
> compound primary key to a unique key of another (dimension) table would
> remain distinct, and so you could drop the DISTINCT from the query.

I'm aware. It is something I'm interested in but would require several
orders of magnitude more work than what I've done for this patch. You
may have noticed the other work I did a while back to detect if joins
cause row duplicate or not, so it's certainly something I've thought
about.

If Amazon would like to sponsor work in this area then please see [1].

It certainly would be great to see that happen.

[1] https://wiki.postgresql.org/wiki/How_to_sponsor_a_feature

-- 
 David Rowley                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: Removing useless DISTINCT clauses
Next
From: legrand legrand
Date:
Subject: Re: Sample values for pg_stat_statements