X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 75CD756786 for ; Mon, 21 Mar 2005 04:11:15 +0000 (GMT) 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 32969-01 for ; Mon, 21 Mar 2005 04:11:03 +0000 (GMT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id 2F3D356655 for ; Mon, 21 Mar 2005 04:11:02 +0000 (GMT) Received: (qmail 27153 invoked by uid 500); 21 Mar 2005 04:27:20 -0000 Date: Sun, 20 Mar 2005 22:27:20 -0600 From: Bruno Wolff III To: Keith Worthington Cc: pgsql-performance@postgresql.org Subject: Re: View vs function Message-ID: <20050321042720.GA27098@wolff.to> Mail-Followup-To: Bruno Wolff III , Keith Worthington , pgsql-performance@postgresql.org References: <423E420D.1020503@NarrowPathInc.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <423E420D.1020503@NarrowPathInc.com> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.01 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/399 X-Sequence-Number: 11104 On Sun, Mar 20, 2005 at 22:39:57 -0500, Keith Worthington wrote: > Hi All, > > I have been reading about set returning functions. What I would like to > know is is there a performance advantage in using SRFs versus querying a > view. Assuming the underlying SQL is the same for the view vs the > function except for the WHERE clause which of these would you expect to > be faster? Or does the planner realize all this... In general you are going to be better off with a view, since the planner knows what the view is doing and there may be some optimizations it can make. Functions are just black boxes to the planner. > > SELECT * FROM view_big_query WHERE column1 = 1234; > > SELECT * FROM func_bug_query(1234); > > -- > Kind Regards, > Keith > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faq