X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8C120D1C4CC for ; Fri, 25 Jul 2003 23:42:01 +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 82726-05 for ; Fri, 25 Jul 2003 20:41:15 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 49F9FD1C4C1 for ; Fri, 25 Jul 2003 20:41:59 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h6PNfrQ3009915; Fri, 25 Jul 2003 19:41:53 -0400 (EDT) To: Jonathan Bartlett Cc: Elielson Fontanezi , "'Stephan Szabo'" , pgsql-general , pgsql-sql Subject: Re: Function index qeustion In-reply-to: References: Comments: In-reply-to Jonathan Bartlett message dated "Fri, 25 Jul 2003 13:26:57 -0700" Date: Fri, 25 Jul 2003 19:41:53 -0400 Message-ID: <9914.1059176513@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/1273 X-Sequence-Number: 46126 Jonathan Bartlett writes: > 1) If you have an index on a cacheable function, does PostgreSQL use the > index instead of calculating the results? Not in general --- only for an indexscan lookup. > 2) How does PostgreSQL know when to recompute the function? Never. That's what the iscachable flag means: you are promising that the function's output for given input never changes. If you aren't prepared to make that promise, you cannot index the function. regards, tom lane