X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7794D475F16 for ; Fri, 25 Apr 2003 11:09:06 -0400 (EDT) Received: from flake.decibel.org (flake.decibel.org [66.93.216.19]) by postgresql.org (Postfix) with SMTP id 99B9D47636C for ; Fri, 25 Apr 2003 11:09:00 -0400 (EDT) Received: (qmail 9776 invoked by uid 1001); 25 Apr 2003 15:09:05 -0000 Date: Fri, 25 Apr 2003 10:09:05 -0500 From: "Jim C. Nasby" To: Frederic Jolliton Cc: pgsql-performance@postgresql.org Subject: Re: Important speed difference between a query and a function with the same query Message-ID: <20030425100905.D66185@flake.decibel.org> Reply-To: jim@nasby.net References: <8665p56qx8.fsf@mau.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <8665p56qx8.fsf@mau.localdomain>; from fred-pg@jolliton.com on Wed, Apr 23, 2003 at 07:53:55PM +0200 X-Operating-System: FreeBSD 4.8-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net X-Spam-Status: No, hits=-38.6 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,SIGNATURE_SHORT_SPARSE, USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/209 X-Sequence-Number: 1715 On Wed, Apr 23, 2003 at 07:53:55PM +0200, Frederic Jolliton wrote: > CREATE FUNCTION get_info (integer) RETURNS SETOF type_get_info > AS '...' <- here the query show below, where 'LIMIT $1' is used instead of 'LIMIT 10' > LANGUAGE sql; You should probably define the function to be STABLE. LANGUAGE sql STABLE; See http://www.postgresql.org/docs/view.php?version=7.3&idoc=1&file=sql-createfunction.html for more info. -- Jim C. Nasby (aka Decibel!) jim@nasby.net Member: Triangle Fraternity, Sports Car Club of America Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?"