Re: What are functional indices good for?

From: Alaric B Snell <abs(at)frontwire(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Patrick L(dot) Nolan" <pln(at)razzle(dot)Stanford(dot)EDU>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: What are functional indices good for?
Date: 2002-03-07 19:09:59
Message-ID: E16j3Hv-00089B-00@calvin.frontwire.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thursday 07 March 2002 17:04, Tom Lane wrote:

> > select * from mytable where func_name(column1, column2) < 3.14159;

> Your question is just a special case of the FAQ "why doesn't Postgres
> use an index for FOO". In this case, I believe that "< 3.14159" is not
> considered a selective enough WHERE condition to justify using the
> index. You would probably see the index used for an equality check
> or range check (eg, func_name(column1, column2) < 3.14159 AND
> func_name(column1, column2) > 1.0).

It strikes me that the selectivity of the query ought to be balanced against
some threshold set based upon an estimate of the compute cost of running the
function itself... some functions might be so resource-intensive to evaluate
that it's worth using the index even for a query that's expected to return
99% of the rows!

ABS

--
Alaric B. Snell, Technical
abs(at)frontwire(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joel Burton 2002-03-07 19:29:53 Re: Problem with Subquery
Previous Message Daniel Åkerud 2002-03-07 19:08:51 Lock up, but not deadlock?