X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id BED329FA15C for ; Tue, 16 May 2006 13:55:36 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 02563-03 for ; Tue, 16 May 2006 13:55:30 -0300 (ADT) X-Greylist: delayed 07:07:00.153595 by SQLgrey- Received: from foggy.rox.net (foggy.rox.net [213.214.0.41]) by postgresql.org (Postfix) with ESMTP id D802D9F9C9E for ; Tue, 16 May 2006 13:55:29 -0300 (ADT) Received: from localhost ([127.0.0.1]) by foggy.rox.net with esmtp (Exim 4.62) (envelope-from ) id 1Fg2pU-0003E5-Lg; Tue, 16 May 2006 18:55:28 +0200 Received: from [87.217.68.213] (helo=mcknight.kawo2.rwth-aachen.de) by foggy.rox.net with esmtpa (Exim 4.62) (envelope-from ) id 1Fg2pT-0003Dg-Mf; Tue, 16 May 2006 18:55:27 +0200 Received: by mcknight.kawo2.rwth-aachen.de (Postfix, from userid 1000) id F2F9D4681A8; Tue, 16 May 2006 18:55:14 +0200 (CEST) Date: Tue, 16 May 2006 18:55:14 +0200 From: Joachim Wieland To: Tom Lane Cc: David Wheeler , pgsql-performance Subject: Re: IMMUTABLE? Message-ID: <20060516165514.GA4424@mcknight.de> References: <2D4C0FA5-DB75-45EA-91D2-7B4F6DD55083@kineticode.com> <5211.1147749711@sss.pgh.pa.us> <3F0CF576-8C6F-433C-9942-BB36F4E1A194@kineticode.com> <5894.1147753901@sss.pgh.pa.us> <20060516094824.GA2376@mcknight.de> <11508.1147786394@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <11508.1147786394@sss.pgh.pa.us> X-Operating-System: Linux 2.6.13.4 on an i686 User-Agent: Mutt/1.5.9i X-Scanned-By: rockenstein AG X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/348 X-Sequence-Number: 19135 On Tue, May 16, 2006 at 09:33:14AM -0400, Tom Lane wrote: > Joachim Wieland writes: > > So irrespective of caching to prevent evaluation across statements, within a > > single statement, is there a strong reason why for example in > > WHERE col = f(const) with f() declared as immutable or stable and without an > > index on col, f() still gets called for every row? Or is this optimization > > just not done yet? > The above statement is not correct, at least not for immutable functions. So an immutable function gets evaluated once but a stable function still gets called for every row? Wouldn't it make sense to call a stable function only once as well? Joachim