X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C1256476373 for ; Thu, 24 Apr 2003 11:47:51 -0400 (EDT) Received: from tux.tuxee.net (tuxee.net [62.212.110.244]) by postgresql.org (Postfix) with ESMTP id 90496476368 for ; Thu, 24 Apr 2003 11:47:48 -0400 (EDT) Received: from mau.localdomain (mau.localdomain [192.168.1.10]) by tux.tuxee.net (8.12.9/8.12.9) with ESMTP id h3OFlri3021850 for ; Thu, 24 Apr 2003 17:47:53 +0200 Received: from mau.localdomain (localhost [127.0.0.1]) by mau.localdomain (8.12.8/8.12.6) with ESMTP id h3OFlrw7006919 for ; Thu, 24 Apr 2003 17:47:53 +0200 Received: (from fred@localhost) by mau.localdomain (8.12.8/8.12.8/Submit) id h3OFlriH006918; Thu, 24 Apr 2003 17:47:53 +0200 X-Authentication-Warning: mau.localdomain: fred set sender to fred@jolliton.com using -f To: pgsql-performance@postgresql.org From: Frederic Jolliton Subject: Re: Important speed difference between a query and a Date: Thu, 24 Apr 2003 17:47:53 +0200 In-Reply-To: <8665p56qx8.fsf@mau.localdomain> (Frederic Jolliton's message of "Wed, 23 Apr 2003 19:53:55 +0200") Message-ID: <86el3rsxqu.fsf@mau.localdomain> User-Agent: Gnus/5.090015 (Oort Gnus v0.15) Emacs/21.3 References: <8665p56qx8.fsf@mau.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-32.9 required=5.0 tests=BAYES_10,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_GNUS_UA,X_AUTH_WARNING 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/196 X-Sequence-Number: 1702 > (PostgreSQL 7.3.2 on i386-portbld-freebsd4.7, compiled by GCC 2.95.4) > > I've a curious performance problem with a function returning set of > rows. The query alone is very fast, but not when called from the > function. > > To "emulate" a parametred view, I created a function as follow: > > CREATE FUNCTION get_info (integer) RETURNS SETOF type_get_info > AS '...' <- here the query show below, where 'LIMIT $1' is used inste= ad of 'LIMIT 10' > LANGUAGE sql; Setting enable_seqscan to off give same result speed between the query and the function ! So, the query in the function is not using index but the exact same query alone does ! Is there an explanation ? --=20 Fr=E9d=E9ric Jolliton