X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7449653653 for ; Sat, 23 Apr 2005 15:01:42 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 53611-04 for ; Sat, 23 Apr 2005 18:01:33 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id CE863535CB for ; Sat, 23 Apr 2005 15:01:29 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7274920; Sat, 23 Apr 2005 11:03:27 -0700 From: Josh Berkus Organization: Aglio Database Solutions To: Kai Hessing Subject: Re: can a function return a virtual table? Date: Sat, 23 Apr 2005 11:00:56 -0700 User-Agent: KMail/1.6.2 Cc: pgsql-sql@postgresql.org References: <3c4m1vF6b6e6aU1@individual.net> In-Reply-To: <3c4m1vF6b6e6aU1@individual.net> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <200504231100.56375.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.009 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200504/360 X-Sequence-Number: 21253 Kai, > It would be much nicer to have to write something like: SELECT xyz, abc > FROM active(tablex); where the function 'active(x)' returns a virtual > table with all entries from table x where status is > -1. But sadly I > have no idea how write such a function. Good old O'reilly can't help (or > i'm to dumb *g*). http://techdocs.postgresql.org/guides/SetReturningFunctions Beware, though, that query plan estimation for SRFs is less accurate than for regular subqueries, so you could end up with unnecessarily slow query execution. Test! -- Josh Berkus Aglio Database Solutions San Francisco