function in index expression and unnecessary function calls in select

Поиск
Список
Период
Сортировка
От Eugene Prokopiev
Тема function in index expression and unnecessary function calls in select
Дата
Msg-id 4392BE54.7060202@stc.donpac.ru
обсуждение исходный текст
Ответы Re: function in index expression and unnecessary function calls in select
Список 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

В списке pgsql-general по дате отправления:

Предыдущее
От: "Qingqing Zhou"
Дата:
Сообщение: Re: keeping track of inserts (periodical) into a table
Следующее
От: Anton Nikiforov
Дата:
Сообщение: Re: int to inet conversion