Re: Is "DISTINCT" making a diffence in: SELECT [DISTINCT] ... EXCEPT - Mailing list pgsql-general

From Erik Wienhold
Subject Re: Is "DISTINCT" making a diffence in: SELECT [DISTINCT] ... EXCEPT
Date
Msg-id p7bccg4lc6o6hehaujpmauh3mymdor33exspwjwq4s4w3sud4m@zwry4unn65wp
Whole thread Raw
In response to Is "DISTINCT" making a diffence in: SELECT [DISTINCT] ... EXCEPT  (Dimitrios Apostolou <jimis@gmx.net>)
Responses Re: Is "DISTINCT" making a diffence in: SELECT [DISTINCT] ... EXCEPT
List pgsql-general
On 2023-11-15 10:57 +0100, Dimitrios Apostolou wrote:
> SELECT [DISTINCT] ... EXCEPT ...
> 
> In this query I get the same results regardless of including DISTINCT or
> not. But I get different query plans, I get an extra HashAggregate node
> in the case of SELECT DISTINCT. Any idea why?

As Tom Lane recently wrote[1] EXCEPT is not optimized and will operate
on the subqueries which are planned independently.

[1] https://www.postgresql.org/message-id/2664450.1698799927@sss.pgh.pa.us

-- 
Erik



pgsql-general by date:

Previous
From: Dimitrios Apostolou
Date:
Subject: Is "DISTINCT" making a diffence in: SELECT [DISTINCT] ... EXCEPT
Next
From: Dimitrios Apostolou
Date:
Subject: Re: Is "DISTINCT" making a diffence in: SELECT [DISTINCT] ... EXCEPT