Re: Removing useless DISTINCT clauses

From: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
To: Jim Finnerty <jfinnert(at)amazon(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Removing useless DISTINCT clauses
Date: 2018-08-23 00:25:04
Message-ID: CAKJS1f_yXt1vFJGegs9qRUwtEtaFBoLLhmA=_avrrs67WhAxNQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 23 August 2018 at 08:11, Jim Finnerty <jfinnert(at)amazon(dot)com> wrote:
> Here is an update to this thread, for potential inclusion in v12. I
> couldn't get the most recent 'v5' patch to apply cleanly, so I recreated a
> v6 patch on PG10.5 by hand, and made a few changes and improvements:

Well, the patch I wrote was never intended for v10. Why did you go to
the effort of doing that when you're proposing the patch for v12? It
seems my v5 patch and Tom's v6 version apply fine to today's master
without any rejected hunks.

> The pg_rewrite catalog contains a serialized representation of the Query
> node in its ev_action column. If there is a way to recreate the contents of
> the pg_rewrite relation without bumping the catversion, can someone please
> explain how? If not, then this change is incomplete and would require a new
> catalog version (catversion.h) too.

If you're proposing for v12, why do you care about that? catversion
changes are commonplace during major version development. Or are you
proposing this gets committed to PostgreSQL 10? ... That's not going
to happen... Plus, it does not seem well aligned with the intent of
this thread to discuss ways to do that either.

> Additional work on this patch would be desirable. It should check for
> unique + not null, in addition to just the pk constraint. The DISTINCT
> could be eliminated in cases with multiple relations if all the joins are
> 1:1, although that would arguably belong in a different patch.

Certainly. Patches are welcome, but I think I've mentioned to you
previously that I'm not planning that for this patch.

> p.s. the v6 patch works for the problem case that Tom Lane reported with the
> v5 patch

That would be less ambiguous if there wasn't now two v6 version of the patch.

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2018-08-23 00:55:06 Re: Speeding up INSERTs and UPDATEs to partitioned tables
Previous Message Andres Freund 2018-08-23 00:19:32 Re: Windows vs C99 (was Re: C99 compliance for src/port/snprintf.c)