Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id AB13A9F9C9E for ; Thu, 7 Dec 2006 12:40:45 -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 18140-04 for ; Thu, 7 Dec 2006 12:40:45 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 2BFE39F9C35 for ; Thu, 7 Dec 2006 12:40:45 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id kB7GeR4n016167; Thu, 7 Dec 2006 11:40:27 -0500 (EST) To: Richard Ray cc: pgsql-sql@postgresql.org Subject: Re: Query is fast and function is slow In-reply-to: References: <200612071053.01287.mlists@rp-online.de> Comments: In-reply-to Richard Ray message dated "Thu, 07 Dec 2006 08:53:31 -0600" Date: Thu, 07 Dec 2006 11:40:26 -0500 Message-ID: <16166.1165509626@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200612/76 X-Sequence-Number: 27032 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. regards, tom lane