Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZdfC8-0004qy-AO for pgsql-sql@arkaria.postgresql.org; Sun, 20 Sep 2015 14:02:20 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZdfC7-0007xI-HB for pgsql-sql@arkaria.postgresql.org; Sun, 20 Sep 2015 14:02:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZdfBA-0006t9-1N for pgsql-sql@postgresql.org; Sun, 20 Sep 2015 14:01:20 +0000 Received: from mail-pa0-x236.google.com ([2607:f8b0:400e:c03::236]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1ZdfB2-0007K0-BE for pgsql-sql@postgresql.org; Sun, 20 Sep 2015 14:01:19 +0000 Received: by pacfv12 with SMTP id fv12so94243709pac.2 for ; Sun, 20 Sep 2015 07:01:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type; bh=1yLeXt+F4HOc8idyzARcM2oP6RG1r6oit5iM9JxoYR8=; b=sxYFzdjYxKQCQx4nUtqmjjrtT4D3/f5xTycXpOblVNeKpnZtBtVSZnNyJRCpq0aqQx CXlJhdw3Yr31VHIGE/drQrJD0V9fpkN9sYQV+wlFpb22m+ZXW/9XKKm/ng0dRS+W7x+F Rsz7SxOWtY1rQXlz2DfvhzdPCRHgd2wIiuFEL+NhKYH8QEN19FxBhD8ozZZZQZLnH+4J MPzULUjtSzmVD0BLTbx7H0OFDcgaVjAsAO5Z063WIL6OXOo3+8SwLezqiRB+amz8wSyK gAKs9zty0KlOwZiscZKpk/g3jIUIip8alr0a7PO3yfJywNSpsiOuePIYMuP1hwAkZpnP XQJQ== X-Received: by 10.68.234.167 with SMTP id uf7mr18638291pbc.51.1442757668678; Sun, 20 Sep 2015 07:01:08 -0700 (PDT) Received: from [10.55.3.8] ([155.100.233.210]) by smtp.googlemail.com with ESMTPSA id qn5sm14324540pbc.74.2015.09.20.07.01.07 for (version=TLSv1/SSLv3 cipher=OTHER); Sun, 20 Sep 2015 07:01:07 -0700 (PDT) Subject: Re: Recursive merging of overlapping arrays in a column To: pgsql-sql@postgresql.org References: <1442747556700-5866560.post@n5.nabble.com> From: Rob Sargent Message-ID: <55FEBBE0.8090902@gmail.com> Date: Sun, 20 Sep 2015 08:00:00 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442747556700-5866560.post@n5.nabble.com> Content-Type: multipart/alternative; boundary="------------090506010307000801020103" X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org This is a multi-part message in MIME format. --------------090506010307000801020103 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit On 09/20/2015 05:12 AM, dave wrote: > Hey mailing list, > > i have the following Table: > > > > I want to merge the arrays which have overlapping elements, so that I get > the result which doesn't contain overlapping arrays anymore: > > > I am not an expert in SQL and it took me a long time to come up with this > solution: > > > Which gives me the result: > > > Result number 3 is contained in number one and shouldn't be in the output > anymore, because I only want non overlapping arrays in the result. > > Another problem I encountered is that the performance of this query seems to > be very bad. I tried running it on a larger table (~400000 arrays) and it is > still running after ~10h. > > I would appreciate any input on this problems, so it would be nice if anyone > could give me a hint how to get only the merged arrays without overlaps in > the resultset and maybe how to build a more elegant and efficient query. > > > Thanks in advance, > > Dave > > > > -- > View this message in context: http://postgresql.nabble.com/Recursive-merging-of-overlapping-arrays-in-a-column-tp5866560.html > Sent from the PostgreSQL - sql mailing list archive at Nabble.com. > > I don't see your table def, sql nor result output. Suggest you re-post with all those as plain text --------------090506010307000801020103 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: 7bit
On 09/20/2015 05:12 AM, dave wrote:
Hey mailing list,

i have the following Table:



I want to merge the arrays which have overlapping elements, so that I get
the result which doesn't contain overlapping arrays anymore:


I am not an expert in SQL and it took me a long time to come up with this
solution:


Which gives me the result:


Result number 3 is contained in number one and shouldn't be in the output
anymore, because I only want non overlapping arrays in the result.

Another problem I encountered is that the performance of this query seems to
be very bad. I tried running it on a larger table (~400000 arrays) and it is
still running after ~10h.

I would appreciate any input on this problems, so it would be nice if anyone
could give me a hint how to get only the merged arrays without overlaps in
the resultset and maybe how to build a more elegant and efficient query.


Thanks in advance,

Dave



--
View this message in context: http://postgresql.nabble.com/Recursive-merging-of-overlapping-arrays-in-a-column-tp5866560.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.


I don't see your table def, sql nor result output. Suggest you re-post with all those as plain text
--------------090506010307000801020103--