Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 54E02632223 for ; Fri, 3 Apr 2009 11:04:09 -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 06999-07 for ; Fri, 3 Apr 2009 11:04:07 -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 865C0632219 for ; Fri, 3 Apr 2009 11:04:07 -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 n33E42Ne028596; Fri, 3 Apr 2009 10:04:02 -0400 (EDT) To: Matthew Wakeling cc: pgsql-performance@postgresql.org Subject: Re: plpgsql arrays In-reply-to: References: <603c8f070904030647u1c92e13ew53612ac0011ed7c1@mail.gmail.com> Comments: In-reply-to Matthew Wakeling message dated "Fri, 03 Apr 2009 14:57:12 +0100" Date: Fri, 03 Apr 2009 10:04:02 -0400 Message-ID: <28595.1238767442@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/63 X-Sequence-Number: 33430 Matthew Wakeling writes: > On Fri, 3 Apr 2009, Robert Haas wrote: >> Why not just use SQL to do the join? > Because the merge condition is: > WHERE l1.start <= l2.end AND l2.start <= l1.end > and merge joins in postgres only currently cope with the case where the > merge condition is an equals relationship. > Oh, hang on, I think I saw something in the docs about what conditions can > be used in a merge... No, you got it right the first time. I was about to suggest that maybe you could make it work by recasting the problem as equality on an interval datatype, but the problem is that this is not equality but "overlaps". And you can't cheat and call it equality, because it's not transitive. I don't actually believe that a standard merge join algorithm will work with an intransitive join condition ... regards, tom lane