Re: [HACKERS] Idea on how to simplify comparing two sets - Mailing list pgsql-hackers

From Pantelis Theodosiou
Subject Re: [HACKERS] Idea on how to simplify comparing two sets
Date
Msg-id CAE3TBxxPpDuZFp+MGkzbfZcS1+__7Lhi2Z9Dct7p9MDqg9DQHg@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] Idea on how to simplify comparing two sets  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers


On Tue, Feb 7, 2017 at 3:58 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Joel Jacobson <joel@trustly.com> writes:
> Currently there is no simple way to check if two sets are equal.

Uh ... maybe check whether SELECT set1 EXCEPT SELECT set2
and SELECT set2 EXCEPT SELECT set1 are both empty?

                        regards, tom lane


Yes, if the wanted result is true or false, something like this:

SELECT EXISTS (TABLE a EXCEPT TABLE b)   OR EXISTS (TABLE b EXCEPT TABLE a) ;

And if a new operator was added (in the same category as UNION and EXCEPT), it could be:


SELECT EXISTS (TABLE a XORSET TABLE b) ;

What about using the = and <> operators in sets? Is the following allowed in the standard?


SELECT (TABLE a) <> (TABLE b) ;

 

pgsql-hackers by date:

Previous
From: Thomas Munro
Date:
Subject: Re: [HACKERS] Parallel tuplesort (for parallel B-Tree index creation)
Next
From: Dilip Kumar
Date:
Subject: Re: [HACKERS] Parallel bitmap heap scan