Re: [HACKERS] Removing useless DISTINCT clauses - Mailing list pgsql-hackers

From David Rowley
Subject Re: [HACKERS] Removing useless DISTINCT clauses
Date
Msg-id CAKJS1f8VXZOFwWf++H5dE2g5-Oskj8+9ypfMUNhWJNN=NR9uWA@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] Removing useless DISTINCT clauses  (Jeff Janes <jeff.janes@gmail.com>)
Responses Re: [HACKERS] Removing useless DISTINCT clauses
List pgsql-hackers
Hi Jeff,

Thanks for looking at the patch.

On 6 January 2018 at 10:34, Jeff Janes <jeff.janes@gmail.com> wrote:
> Couldn't the Unique node be removed entirely?  If k is a primary key, you
> can't have duplicates in need of removal.

It probably could be, if there were no joins, but any join could
duplicate those rows, so we'd only be able to do that if there were no
joins, and I'm not sure we'd want to special case that. It seems just
too naive to be taken seriously. We could do a lot better...

> Or would that be a subject for a different patch?

Yeah, I'd rather do that fix properly, and do have ideas on how to,
just it's a lot more work (basically testing if the joins can
duplicate rows or not (unique joins++)).

> I think remove_functionally_dependant_groupclauses should have a more
> generic name, like remove_functionally_dependant_clauses.

It's been a while since I looked at this. I remember thinking
something similar at the time but I must have not changed it.

I'll look again and post an updated patch.

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


pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: [HACKERS] Creating backup history files for backups taken from standbys
Next
From: David Rowley
Date:
Subject: Re: [HACKERS] Runtime Partition Pruning