Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 86CBD9F9C35 for ; Thu, 7 Dec 2006 13:11:03 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 26912-05 for ; Thu, 7 Dec 2006 13:11:02 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from itspmx2.state.ms.us (itspmx2.state.ms.us [205.144.224.112]) by postgresql.org (Postfix) with ESMTP id E948F9F9386 for ; Thu, 7 Dec 2006 13:11:02 -0400 (AST) Received: from rray.drdc.mstc.ms.gov ([10.3.192.2]) by itspmx2.state.ms.us (8.13.4/8.13.4) with ESMTP id kB7HAuaj028931 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 7 Dec 2006 11:11:01 -0600 (CST) Received: from rray.drdc.mstc.ms.gov (localhost.localdomain [127.0.0.1]) by rray.drdc.mstc.ms.gov (8.13.6/8.13.6) with ESMTP id kB7HAuBj025459 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 7 Dec 2006 11:10:56 -0600 Received: from localhost (rray@localhost) by rray.drdc.mstc.ms.gov (8.13.6/8.13.6/Submit) with ESMTP id kB7HAuAA025456 for ; Thu, 7 Dec 2006 11:10:56 -0600 X-Authentication-Warning: rray.drdc.mstc.ms.gov: rray owned process doing -bs Date: Thu, 7 Dec 2006 11:10:56 -0600 (CST) From: Richard Ray X-X-Sender: rray@rray.drdc.mstc.ms.gov To: pgsql-sql@postgresql.org Subject: Re: Query is fast and function is slow In-Reply-To: <16166.1165509626@sss.pgh.pa.us> Message-ID: References: <200612071053.01287.mlists@rp-online.de> <16166.1165509626@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Archive-Number: 200612/77 X-Sequence-Number: 27033 On Thu, 7 Dec 2006, Tom Lane wrote: > Richard Ray writes: >> On Thu, 7 Dec 2006, Thomas Pundt wrote: >>> Just a guess: is the column "doc_num" really of type text? Maybe using "text" >>> in the function lets the planner choose a sequential scan? > >> Actually "doc_num" is char(9) >> I changed text to char(9) and got same slow results > > You need to make the second argument type "name", too, if you have a lot > of users. I said my knowledge was pitiful Changing both parameters to char(9) and name fixed the problem It appears to be using the index If time allows could you explain this a bit Thanks Richard > > regards, tom lane > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Have you searched our list archives? > > http://archives.postgresql.org >