Re: [HACKERS] Removing useless DISTINCT clauses

2018-03-04 Thread David Rowley
On 10 January 2018 at 09:26, Tom Lane wrote: > 1. Once you don't have all the tlist items shown in DISTINCT, it really is > more like DISTINCT ON, seems like. I am not sure it's a good idea to set > hasDistinctOn, because that engages some planner behaviors we probably > don't want, but I'm also

Re: [HACKERS] Removing useless DISTINCT clauses

2018-03-01 Thread David Rowley
On 2 March 2018 at 09:51, Andres Freund wrote: > This patch has been waiting on author since 2018-01-09, the next & last > CF has started. I'm inclined to mark this as returned with feedback. I'm planning on making the required changes at the weekend. -- David Rowley http://

Re: [HACKERS] Removing useless DISTINCT clauses

2018-03-01 Thread Andres Freund
Hi, On 2018-01-10 11:12:17 +1300, David Rowley wrote: > I'll do some more analysis on places that distinctClause is being used > to check what's safe. This patch has been waiting on author since 2018-01-09, the next & last CF has started. I'm inclined to mark this as returned with feedback. Gree

Re: [HACKERS] Removing useless DISTINCT clauses

2018-01-09 Thread David Rowley
Hi Tom, Thanks for looking at this. On 10 January 2018 at 09:26, Tom Lane wrote: > This is a cute idea, but I'm troubled by a couple of points: > > 1. Once you don't have all the tlist items shown in DISTINCT, it really is > more like DISTINCT ON, seems like. I am not sure it's a good idea to s

Re: [HACKERS] Removing useless DISTINCT clauses

2018-01-09 Thread Tom Lane
David Rowley writes: > [ remove_useless_distinct_clauses_v2.patch ] This is a cute idea, but I'm troubled by a couple of points: 1. Once you don't have all the tlist items shown in DISTINCT, it really is more like DISTINCT ON, seems like. I am not sure it's a good idea to set hasDistinctOn, bec

Re: [HACKERS] Removing useless DISTINCT clauses

2018-01-06 Thread David Rowley
On 6 January 2018 at 23:08, David Rowley wrote: >> 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 no

Re: [HACKERS] Removing useless DISTINCT clauses

2018-01-06 Thread David Rowley
Hi Jeff, Thanks for looking at the patch. On 6 January 2018 at 10:34, Jeff Janes 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,

Re: [HACKERS] Removing useless DISTINCT clauses

2018-01-05 Thread Jeff Janes
On Mon, Nov 6, 2017 at 1:16 AM, David Rowley wrote: > In [1] we made a change to process the GROUP BY clause to remove any > group by items that are functionally dependent on some other GROUP BY > items. > > This really just checks if a table's PK columns are entirely present > in the GROUP BY cl