Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 15A67476494 for ; Wed, 16 Oct 2002 09:46:10 -0400 (EDT) Received: from out.juza.com (out.juza.com [212.108.195.66]) by postgresql.org (Postfix) with ESMTP id 3BE32476574 for ; Wed, 16 Oct 2002 09:45:38 -0400 (EDT) content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: Re: set difference X-MimeOLE: Produced By Microsoft Exchange V6.0.5762.3 Date: Wed, 16 Oct 2002 15:44:42 +0200 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [SQL] set difference Thread-Index: AcJ0VqHG89md9qz+R+eUg2Oihz7PkwAw3BGg From: =?iso-8859-1?Q?Domoszlai_L=E1szl=F3?= To: "Tom Lane" Cc: "SQL PostgreSQL (E-mail)" X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/175 X-Sequence-Number: 9892 Tom Lane wrote: > > I would like to make symmetrical(set) difference in a query. > > But the simpliest way I could find is=20 >=20 > > select id from a=20 > > except > > select id from b > > union=20 > > select id from b > > except > > select id from a >=20 > > Is there any better solution for this problem? >=20 > One thing you should definitely do is change "union" to "union all". > "union" implies a pass of duplicate removal, which shouldn't be > necessary here (unless a or b individually contain duplicates and > you want to get rid of those too). >=20 > Another thing to try is > (a union b) except (a intersect b) > (Again, you might be able to say union all instead of union.) > Not sure which will be faster. It's likely faster but my problem is I have to run queries twice. I've look= ed at=20 setOp executor and it seems symmetrical differencial can run as time as an = EXCEPT. I would write it, because it speeds up my query very much, but I don't know= if it is worth. So, do you think a DIFFERENCE or EXCEPT SYMMETRIC clause w= ill be reasonable=20 feauture for postgresql? Laca