Re: [HACKERS] Idea on how to simplify comparing two sets

Поиск
Список
Период
Сортировка
От Nico Williams
Тема Re: [HACKERS] Idea on how to simplify comparing two sets
Дата
Msg-id 20170223212743.GD30233@localhost
обсуждение исходный текст
Ответ на Re: [HACKERS] Idea on how to simplify comparing two sets  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Tue, Feb 07, 2017 at 10:58:41AM -0500, Tom Lane 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?

Even better, NATURAL(*) FULL OUTER JOIN the two table sources and check
that the result is empty.  If the two sources have useful indices (or if
PG constructs suitable automatic indices for them) for this then the
query should be O(N).

(*) However, if you do this then there'd better not be any NULLs in
columns, otherwise you'll get false positives for differences.  Of
course, if the two table sources have common primary key prefixes and
you only care about equality in those columns, then just FULL OUTER JOIN
USING (<primary key prefix>).

Nico
-- 



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Jim Nasby
Дата:
Сообщение: Re: [HACKERS] PinBuffer() no longer makes use of strategy
Следующее
От: Corey Huinker
Дата:
Сообщение: Re: [HACKERS] Idea on how to simplify comparing two sets