Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 1ED486322C7 for ; Fri, 3 Apr 2009 11:48:41 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 56565-01 for ; Fri, 3 Apr 2009 11:48:39 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 86BB7632223 for ; Fri, 3 Apr 2009 11:48:39 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id n33EmWHk001139; Fri, 3 Apr 2009 10:48:32 -0400 (EDT) To: Matthew Wakeling cc: pgsql-performance@postgresql.org Subject: Re: plpgsql arrays In-reply-to: References: <603c8f070904030647u1c92e13ew53612ac0011ed7c1@mail.gmail.com> <28595.1238767442@sss.pgh.pa.us> <29730.1238768681@sss.pgh.pa.us> Comments: In-reply-to Matthew Wakeling message dated "Fri, 03 Apr 2009 15:28:34 +0100" Date: Fri, 03 Apr 2009 10:48:31 -0400 Message-ID: <1138.1238770111@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200904/69 X-Sequence-Number: 33436 Matthew Wakeling writes: > On Fri, 3 Apr 2009, Tom Lane wrote: >> Not unless you have sorted the inputs in some way that has more >> knowledge than the "equal" operator represents. Otherwise you can have >> elements drop out that might still be needed to match to a later >> left-hand element. > Of course. You certainly have to choose a sort order that works. Sorting > by the start field would be sufficient in this case. Uh, no, it wouldn't. Visually: L1 ------------------------- L2 ----------- L3 --------------------- R1 -------- At L2, you'd conclude that you're done matching R1. Intuitively, it seems like 1-D "overlaps" is a tractable enough operator that you should be able to make something merge-like work. But it's more complicated than I think you realize. regards, tom lane