function in index expression and unnecessary function calls in select

From: Eugene Prokopiev <prokopiev(at)stc(dot)donpac(dot)ru>
To: pgsql-general(at)postgresql(dot)org
Subject: function in index expression and unnecessary function calls in select
Date: 2005-12-04 10:00:52
Message-ID: 4392BE54.7060202@stc.donpac.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I have Linux, PostgreSQL 8.1, Python 2.3

pgsql code:

test=# create table t1(name varchar(10), value integer);
CREATE TABLE
test=# create or replace function f1(integer) returns integer as $$
test$# file = open('/tmp/f1.log', 'a')
test$# file.write('log\n')
test$# file.close
test$# return args[0]+1
test$# $$ language plpythonu immutable;
CREATE FUNCTION
test=# select name, f1(value) from t1;
name | f1
------+----
r1 | 2
r2 | 3
(records: 2)

$ cat /tmp/f1.log
log
log

After creating index:

test=# create index i1 on t1 (f1(value));
CREATE INDEX

$ cat /tmp/f1.log
log
log
log
log

After select:

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?

--
Thanks,
Eugene Prokopiev

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Anton Nikiforov 2005-12-04 10:06:52 Re: int to inet conversion
Previous Message Laurent Herve 2005-12-04 09:10:41 Fwd: Enhancement Request : Expressions for format string in PlPgsql RAISE statement