Re: Is "DISTINCT" making a diffence in: SELECT [DISTINCT] ... EXCEPT

From: Erik Wienhold <ewie(at)ewie(dot)name>
To: Dimitrios Apostolou <jimis(at)gmx(dot)net>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Is "DISTINCT" making a diffence in: SELECT [DISTINCT] ... EXCEPT
Date: 2023-11-15 10:59:20
Message-ID: p7bccg4lc6o6hehaujpmauh3mymdor33exspwjwq4s4w3sud4m@zwry4unn65wp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dimitrios Apostolou 2023-11-15 11:12:43 Re: Is "DISTINCT" making a diffence in: SELECT [DISTINCT] ... EXCEPT
Previous Message Dimitrios Apostolou 2023-11-15 09:57:53 Is "DISTINCT" making a diffence in: SELECT [DISTINCT] ... EXCEPT