Re: Index not used in functions in 7.0?

From: Kyle Bateman <kyle(at)actarg(dot)com>
To: mig(at)utdt(dot)edu
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Index not used in functions in 7.0?
Date: 2000-05-16 18:13:10
Message-ID: 39218FB6.450431A8@actarg.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

mig(at)utdt(dot)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.

Attachment Content-Type Size
kyle.vcf text/x-vcard 291 bytes

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2000-05-16 19:11:56 Re: Index not used in functions in 7.0?
Previous Message mig 2000-05-16 18:00:21 Re: Index not used in functions in 7.0?