Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 9C14C64FF77 for ; Thu, 17 Jul 2008 20:41:33 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 31048-01 for ; Thu, 17 Jul 2008 20:41:24 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mailfilter2.une.edu.au (mailhub.une.edu.au [129.180.1.42]) by postgresql.org (Postfix) with ESMTP id 2B4AD64FCEE for ; Thu, 17 Jul 2008 20:41:29 -0300 (ADT) X-ASG-Debug-ID: 1216338082-607803000000-zW6XKP X-Barracuda-URL: http://129.180.1.42:8000/cgi-bin/mark.cgi Received: from [129.180.49.116] (localhost [127.0.0.1]) by mailfilter2.une.edu.au (Spam Firewall) with ESMTP id C6FCA694F16; Fri, 18 Jul 2008 09:41:22 +1000 (EST) Received: from [129.180.49.116] (agbu-klint.une.edu.au [129.180.49.116]) by mailfilter2.une.edu.au with ESMTP id kvXc0rFUlKewnjFm; Fri, 18 Jul 2008 09:41:22 +1000 (EST) Message-ID: <487FD8A3.6080405@une.edu.au> Date: Fri, 18 Jul 2008 09:41:23 +1000 From: Klint Gore User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 To: Kevin Duffy CC: pgsql-general@postgresql.org X-ASG-Orig-Subj: Re: [GENERAL] query optimization Subject: Re: query optimization References: In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Barracuda-Connect: agbu-klint.une.edu.au[129.180.49.116] X-Barracuda-Start-Time: 1216338082 X-Barracuda-Virus-Scanned: by UNE email spam and virus firewall 2 at une.edu.au X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200807/653 X-Sequence-Number: 135232 Kevin Duffy wrote: > > So here are the questions for the PSQL gurus: > > Is getsectypekey(‘CFD’) executing for every join (or possible join) > between positions_gsco and security? > > Causing a scan of security for every possible join. > > Does ‘ (select getsectypekey('CFD') ) ‘ cause the getsectype() > function to be executed once and thus > > allowing the index on security to be used. > > And of couse ‘5’ makes things simple. The index on security is used. > > Am I posting this in the right. If not please help me correct my error > and point me to the correct spot. > Is the function stable or volatile? As Scott Marlowe suggested, you need to look at the explain results to find out what the plan is in each case. klint. -- Klint Gore Database Manager Sheep CRC A.G.B.U. University of New England Armidale NSW 2350 Ph: 02 6773 3789 Fax: 02 6773 3266 EMail: kgore4@une.edu.au