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

Поиск
Список
Период
Сортировка
От Vitalii Tymchyshyn
Тема Re: array_except -- Find elements that are not common to both arrays
Дата
Msg-id 4E85B4AF.2090104@gmail.com
обсуждение исходный текст
Ответ на Re: array_except -- Find elements that are not common to both arrays  (bricklen <bricklen@gmail.com>)
Ответы Re: array_except -- Find elements that are not common to both arrays  (bricklen <bricklen@gmail.com>)
Re: array_except -- Find elements that are not common to both arrays  (bricklen <bricklen@gmail.com>)
Re: array_except -- Find elements that are not common to both arrays  (Gavin Flower <GavinFlower@archidevsys.co.nz>)
Список pgsql-performance
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

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

Предыдущее
От: Gregg Jaskiewicz
Дата:
Сообщение: Re: PostgreSQL-9.0 Monitoring System to improve performance
Следующее
От: bricklen
Дата:
Сообщение: Re: array_except -- Find elements that are not common to both arrays