Re: function in index expression and unnecessary function calls in select

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Eugene Prokopiev <prokopiev(at)stc(dot)donpac(dot)ru>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: function in index expression and unnecessary function calls in select
Date: 2005-12-04 10:07:21
Message-ID: 20051204100721.GB4883@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, Dec 04, 2005 at 01:00:52PM +0300, Eugene Prokopiev wrote:
> Hi,
>
> I have Linux, PostgreSQL 8.1, Python 2.3
>

<snip>

> test=# select name, f1(value) from t1;
> name | f1
> ------+----
> r1 | 2
> r2 | 3
> (records: 2)
>
> $ cat /tmp/f1.log
> log
> log
> log
> log
> log
> log
>
> Why f1 was called in last case? Why select can't use index values
> instead of function call results? Is it bug? Can it be configured?

Because an index is for sorting or finding rows in a table, not for storing
data. Function indexes are to make is quicker to find certain types of
data. The index may not even store the results of f1().

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Anton Nikiforov 2005-12-04 11:09:53 Re: int to inet conversion
Previous Message Anton Nikiforov 2005-12-04 10:06:52 Re: int to inet conversion