Re: Idea on how to simplify comparing two sets

From: Pantelis Theodosiou <ypercube(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Joel Jacobson <joel(at)trustly(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Idea on how to simplify comparing two sets
Date: 2017-02-08 09:13:49
Message-ID: CAE3TBxxPpDuZFp+MGkzbfZcS1+__7Lhi2Z9Dct7p9MDqg9DQHg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Feb 7, 2017 at 3:58 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Joel Jacobson <joel(at)trustly(dot)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) ;

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip Kumar 2017-02-08 09:20:16 Re: Parallel bitmap heap scan
Previous Message Thomas Munro 2017-02-08 07:40:41 Re: Parallel tuplesort (for parallel B-Tree index creation)