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 D2E4F538AD for ; Fri, 8 Apr 2005 23:46:09 +0100 (BST) 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 65805-05 for ; Fri, 8 Apr 2005 22:46:04 +0000 (GMT) Received: from sunsite.dcc.uchile.cl (sunsite.dcc.uchile.cl [192.80.24.2]) by svr1.postgresql.org (Postfix) with ESMTP id D722953883 for ; Fri, 8 Apr 2005 23:46:03 +0100 (BST) Received: from anakena.dcc.uchile.cl (anakena [192.80.24.6]) by sunsite.dcc.uchile.cl (8.12.11/8.12.11) with ESMTP id j38Mjv0e004762; Fri, 8 Apr 2005 18:45:57 -0400 (CLT) Received: by anakena.dcc.uchile.cl (Postfix, from userid 4151) id ECAF2529D0; Fri, 8 Apr 2005 18:45:56 -0400 (CLT) Date: Fri, 8 Apr 2005 18:45:56 -0400 From: Alvaro Herrera To: Michael Fuhr Cc: Josh Berkus , pgsql-performance@postgresql.org Subject: Re: Functionscan estimates Message-ID: <20050408224556.GC19458@dcc.uchile.cl> References: <200504081515.50340.josh@agliodbs.com> <20050408223820.GA17450@winnie.fuhr.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20050408223820.GA17450@winnie.fuhr.org> User-Agent: Mutt/1.5.8i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.345 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE X-Spam-Level: X-Archive-Number: 200504/181 X-Sequence-Number: 11578 On Fri, Apr 08, 2005 at 04:38:20PM -0600, Michael Fuhr wrote: > On Fri, Apr 08, 2005 at 03:15:50PM -0700, Josh Berkus wrote: > > > > I'm wondering if it might be useful to be able to add estimated selectivity to > > a function definition for purposes of query estimation. Currently function > > scans automatically return a flat default 1000 estimated rows. It seems > > like the DBA ought to be able to ALTER FUNCTION and give it a row estimate > > for planning purposes. > > About a month ago I mentioned that I'd find that useful. In a > followup, Christopher Kings-Lynne brought up the idea of a GUC > variable that could give hints about the expected row count. That seems pretty limited ... what happens if the query contains more that one SRF? Maybe issuing some sort of special call to the function (say, with some boolean in the call info struct) on which it returns planning data; thus the planner can call the function itself. The hard part would be figuring out how to do it without breaking backwards compatibility with functions that don't know how to handle that. (And how to do it in plpgsql). -- Alvaro Herrera () "La principal característica humana es la tontería" (Augusto Monterroso)