Re: array_except -- Find elements that are not common to both arrays

Поиск
Список
Период
Сортировка
От Gavin Flower
Тема Re: array_except -- Find elements that are not common to both arrays
Дата
Msg-id 4E8AB2D7.2010901@archidevsys.co.nz
обсуждение исходный текст
Ответ на Re: array_except -- Find elements that are not common to both arrays  (Vitalii Tymchyshyn <tivv00@gmail.com>)
Ответы Re: array_except -- Find elements that are not common to both arrays  (Merlin Moncure <mmoncure@gmail.com>)
Список pgsql-performance
On 01/10/11 01:23, Vitalii Tymchyshyn wrote:
> Since you are using except and not except all, you are not looking at
> arrays with duplicates.
> For this case next function what the fastest for me:
>
> create or replace function array_except2(anyarray,anyarray) returns
> anyarray as $$
> select ARRAY(
> (
> select r.elements
> from    (
>         (select 1,unnest($1))
>         union all
>         (select 2,unnest($2))
>         ) as r (arr, elements)
>     group by 1
>     having min(arr)=max(arr)
> ))
> $$ language sql strict immutable;
>
> Best regards, Vitalii Tymchyshyn
>
Very neat!

I could see that this function could trivially be modified to handle 3
arrays.

QUESTION: Could this be modified to take an arbitrary number of arrays?

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

Предыдущее
От: "Soporte @ TEKSOL S.A."
Дата:
Сообщение: pkey is not used on productive database
Следующее
От: hubert depesz lubaczewski
Дата:
Сообщение: Re: pkey is not used on productive database