X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 9761E9DCA1C for ; Wed, 25 Jan 2006 13:53:48 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 30954-08 for ; Wed, 25 Jan 2006 13:53:47 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by postgresql.org (Postfix) with ESMTP id D4CBE9DCA09 for ; Wed, 25 Jan 2006 13:53:45 -0400 (AST) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id k0PHrds9028610 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 25 Jan 2006 10:53:42 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.4/8.13.4) with ESMTP id k0PHrdnC076433; Wed, 25 Jan 2006 10:53:39 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.4/8.13.4/Submit) id k0PHrdrc076432; Wed, 25 Jan 2006 10:53:39 -0700 (MST) (envelope-from mfuhr) Date: Wed, 25 Jan 2006 10:53:38 -0700 From: Michael Fuhr To: andrew Cc: pgsql-sql@postgresql.org Subject: Re: filtering after join Message-ID: <20060125175338.GA76400@winnie.fuhr.org> References: <29d3b0b90601250927o2a5ee6e6mc33a7647da4438ce@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <29d3b0b90601250927o2a5ee6e6mc33a7647da4438ce@mail.gmail.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.109 required=5 tests=[AWL=0.109] X-Spam-Score: 0.109 X-Spam-Level: X-Archive-Number: 200601/169 X-Sequence-Number: 23958 On Wed, Jan 25, 2006 at 06:27:33PM +0100, andrew wrote: > I want to use a UDF to filter tuples t that are generated after a join. > More specifially, I have a UDF foo(record), which computes a value for > a given tuple. I can do the filtering before the join. e.g.: > > select * from A, B where foo(A)<2 and A.a=B.b; > > But I want to apply foo() to the tuples generated by the join > operation. How can I do that? Is this what you're looking for? select * from (select * from A, B where A.a = B.b) as s where foo(s) < 2; -- Michael Fuhr