Received: from www.actarg.com (root@[209.180.91.25]) by hub.org (8.9.3/8.9.3) with ESMTP id OAA60847 for ; Tue, 16 May 2000 14:13:13 -0400 (EDT) (envelope-from kyle@actarg.com) Received: from actarg.com (root@[192.168.2.16]) by www.actarg.com (8.8.7/8.8.7) with ESMTP id LAA18023; Tue, 16 May 2000 11:14:25 -0600 Received: from actarg.com (IDENT:kyle@localhost [127.0.0.1]) by actarg.com (8.9.3/8.9.3) with ESMTP id MAA09544; Tue, 16 May 2000 12:13:10 -0600 Message-ID: <39218FB6.450431A8@actarg.com> Date: Tue, 16 May 2000 12:13:10 -0600 From: Kyle Bateman Organization: Action Target Inc X-Mailer: Mozilla 4.7 [en] (X11; I; Linux 2.2.12-20 i686) X-Accept-Language: en MIME-Version: 1.0 To: mig@utdt.edu CC: pgsql-sql@postgresql.org Subject: Re: Index not used in functions in 7.0? References: <3921689A.B70CFAC8@actarg.com> <21401.958492203@sss.pgh.pa.us> <21654.958494988@sss.pgh.pa.us> <200005161800.PAA21319@ant.utdt> Content-Type: multipart/mixed; boundary="------------2C66A82716826C09704CB159" X-Archive-Number: 200005/19 This is a multi-part message in MIME format. --------------2C66A82716826C09704CB159 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit mig@utdt.edu wrote: > I am probably completely wrong, but at least it will be short ... > > Could it be that > select sum(tquant) > from mtr_reg > where to_proj = $2 > and pnum = $1 > and (status = 'clsd' or status = 'open' or status = 'prip') > ; > makes it harder for the optimizer due to the ORs, and that > select sum(tquant) > from mtr_reg > where to_proj = $2 > and pnum = $1 > and status in ('clsd','open','prip') > --- last line changed > ; > would produce a better cost estimate? > > Miguel Sofer Thanks for the input. Your point might be correct, but my results are the same regardless of the clause attached to the status field. In one of my tests, the query simply had "and status = 'clsd'." The issue here is that a sequential scan is being chosen over an indexed scan when the query is run from within a function. --------------2C66A82716826C09704CB159 Content-Type: text/x-vcard; charset=us-ascii; name="kyle.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Kyle Bateman Content-Disposition: attachment; filename="kyle.vcf" begin:vcard n:Bateman;Kyle tel;fax:801-377-8096 tel;work:801-377-8033x101 x-mozilla-html:FALSE url:www.actiontarget.com org:Action Target Inc adr:;;PO Box 636;Provo;UT;84603;US version:2.1 email;internet:kyle@actiontarget.com title:President x-mozilla-cpt:;-15520 fn:Kyle Bateman end:vcard --------------2C66A82716826C09704CB159--