Re: Remove redundant DISTINCT when GROUP BY already guarantees uniqueness - Mailing list pgsql-hackers

From Zsolt Parragi
Subject Re: Remove redundant DISTINCT when GROUP BY already guarantees uniqueness
Date
Msg-id CAN4CZFNxk22cGswV6HBkgws3z=QTc5CULKmdOY3A8_LY=NcSVw@mail.gmail.com
Whole thread
In response to Remove redundant DISTINCT when GROUP BY already guarantees uniqueness  (Ilia Evdokimov <ilya.evdokimov@tantorlabs.com>)
Responses Re: Remove redundant DISTINCT when GROUP BY already guarantees uniqueness
List pgsql-hackers
Hello!

+static bool
+distinct_redundant_by_groupby(Query *parse)

I think this also should check hasTargetSRFs:

CREATE TABLE t (a int, b int, c int);
INSERT INTO t VALUES (1,1,10),(1,2,20),(2,1,30),(2,2,40),(1,1,50);
SELECT DISTINCT a, unnest(ARRAY[1,1]) AS u FROM t GROUP BY a ORDER BY a, u;

Also, query_is_distinct_for already does something similar (and
already handles hasTargetSRFs) - would it be possible to extract the
common part instead of duplicating the logic?



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: (SQL/PGQ) cache lookup failed for label
Next
From: Zsolt Parragi
Date:
Subject: Re: [PATCH] Add pg_get_table_ddl() to reconstruct CREATE TABLE statements