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

2011-10-04 Thread Merlin Moncure
On Tue, Oct 4, 2011 at 2:16 AM, Gavin Flower wrote: > 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_e

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

2011-10-04 Thread Gavin Flower
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( ( sele

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

2011-09-30 Thread bricklen
On Fri, Sep 30, 2011 at 2:12 PM, Merlin Moncure wrote: >> FWIW, speaking as somebody who has no need of this function, "array_xor" is >> a pretty clear name that indicates what's going to happen. > > +1 on this -- was going to suggest until you beat me to it.  I also > for the record really think

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

2011-09-30 Thread Merlin Moncure
On Fri, Sep 30, 2011 at 3:15 PM, Ben Chobot wrote: > > On Sep 30, 2011, at 12:07 PM, bricklen wrote: > >> I've been informed that this type of operation is called "symmetric >> difference"[1], and can be represented by A ∆ B.  A couple of >> alternative names were proposed, "array_symmetric_differ

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

2011-09-30 Thread Ben Chobot
On Sep 30, 2011, at 12:07 PM, bricklen wrote: > I've been informed that this type of operation is called "symmetric > difference"[1], and can be represented by A ∆ B. A couple of > alternative names were proposed, "array_symmetric_difference" and > "array_xor". > Does anyone have a preference fo

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

2011-09-30 Thread bricklen
On Fri, Sep 30, 2011 at 5:23 AM, 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

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

2011-09-30 Thread bricklen
On Fri, Sep 30, 2011 at 5:23 AM, 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

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

2011-09-30 Thread Vitalii Tymchyshyn
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,unne

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

2011-09-29 Thread bricklen
On Thu, Sep 29, 2011 at 8:08 PM, Merlin Moncure wrote: > *) Prefer union all to union > *) prefer array constructor to array_agg when not grouping. > *) perhaps consider not reusing 'except' name with different semantic > meaning > > Well done > merlin (on phone & in bed) Hi Merlin, Thanks for t

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

2011-09-29 Thread Merlin Moncure
On Thursday, September 29, 2011, bricklen wrote: > I recently had need of an "array_except" function but couldn't find > any good/existing examples. Based off the neat "array_intersect" > function at http://www.postgres.cz/index.php/PostgreSQL_SQL_Tricks#Intersection_of_arrays , > I put together a

[PERFORM] array_except -- Find elements that are not common to both arrays

2011-09-29 Thread bricklen
I recently had need of an "array_except" function but couldn't find any good/existing examples. Based off the neat "array_intersect" function at http://www.postgres.cz/index.php/PostgreSQL_SQL_Tricks#Intersection_of_arrays, I put together an "array_except" version to return the array elements that