Re: Removing useless DISTINCT clauses

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Melanie Plageman <melanieplageman(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Cc: David Rowley <dgrowley(at)gmail(dot)com>
Subject: Re: Removing useless DISTINCT clauses
Date: 2018-03-22 08:16:52
Message-ID: 1521706612.2459.27.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Melanie Plageman wrote:
> Contents & Purpose
> ==================
>
> This patch removes any additional columns in the DISTINCT clause when the
> table's primary key columns are entirely present in the DISTINCT clause. This
> optimization works because the PK columns functionally determine the other
> columns in the relation. The patch includes regression test cases.

Would it be very difficult to extend that to "if any unique constraints are
contained in the DISTINCT clause"?

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jaime Soler 2018-03-22 08:56:21 Re: Hash join in SELECT target list expression keeps consuming memory
Previous Message Simon Riggs 2018-03-22 08:06:41 Re: [HACKERS] MERGE SQL Statement for PG11