X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 45863D1C7F8 for ; Wed, 30 Jul 2003 02:57:25 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 14351-10 for ; Tue, 29 Jul 2003 23:56:29 -0300 (ADT) Received: from spiff.astoria.bogus (dsl027-144-149.nyc1.dsl.speakeasy.net [216.27.144.149]) by svr1.postgresql.org (Postfix) with ESMTP id 5515BD1C934 for ; Tue, 29 Jul 2003 23:57:23 -0300 (ADT) Received: from spiff.astoria.bogus (localhost.localdomain [127.0.0.1]) by spiff.astoria.bogus (8.12.8/8.12.8) with ESMTP id h6U2vRTC002281; Tue, 29 Jul 2003 22:57:27 -0400 Received: (from meb@localhost) by spiff.astoria.bogus (8.12.8/8.12.8/Submit) id h6U2vRLo002279; Tue, 29 Jul 2003 22:57:27 -0400 Date: Tue, 29 Jul 2003 22:57:27 -0400 From: Mark Bronnimann To: Rod Taylor Cc: pgsql-sql@postgresql.org Subject: Re: function returning setof performance question Message-ID: <20030730025727.GA2094@spiff.astoria.bogus> References: <20030730020859.GA1795@spiff.astoria.bogus> <1059532098.54325.23.camel@jester> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1059532098.54325.23.camel@jester> User-Agent: Mutt/1.4.1i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/442 X-Sequence-Number: 14556 Thanks for the reply. I was hoping to eliminate the parse call on the view because I was doing the where clause on the view instead of putting the where in the view. In all, I was hoping to keep a single view called from multiple functions with different where clauses. Yep... I shoulda known better... Thanks again! And Rod Taylor (rbt@rbt.ca) said...: > > The performance hit is tiny, we're talking less than 1/2 a second, > > but when I've done this sort of thing in Oracle I've seen a performance > > increase, not a decrease. > > Thats just plain strange (never tried on Oracle). Why in the world > would adding the overhead of a function call (with no other changes) > increase performance? > > The function has additional overhead in the form of the plpgsql > interpreter. You may find a c function will give close to identical > performance as with the standard view so long as the query is the same. > > > One thing to keep in mind is that the view can be rearranged to give a > better query overall. The exact work completed for the view may be > different when called from within a different SQL statement. Most > functions -- some SQL language based functions are strange this way -- > cannot do this > -- Mark Bronnimann meb@speakeasy.net -- Let's organize this thing and take all the fun out of it. --