Why indexes are not used when scanning from functions?

From: "Ловпаче Айдамир" <aidanet(at)yandex(dot)ru>
To: pgsql-sql(at)postgresql(dot)org
Subject: Why indexes are not used when scanning from functions?
Date: 2001-05-18 23:30:04
Message-ID: 3B05B07C.000001.06516@camay.yandex.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

The table (script followed) contains more than 200000 records.
When I directly selecting records by the single select statement

select fio from patient_temp where fio like 'something%';

Postgres uses the index i have created and quickly returns the results. But if that query included into the function, slowest sequent scan starts. Is it a normal postgres behavior - not using indexes in functions? Or how to make indexes usable in functions?
I have tried PL/pgSQL, and have got the same result.

create table patient_temp(
code serial primary key,
fio varchar(80)
);

create index fio_patient_temp_ind on patient_temp(fio);

create function get_fio1(text) returns varchar
as 'select fio from patient_temp where fio like $1::text || \'%\';'
language 'sql';

Aidamir Lovpache <aidanet(at)yandex(dot)ru>

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Mikheev, Vadim 2001-05-19 00:28:48 RE: [HACKERS] Re: possible row locking bug in 7.0.3 & 7.1
Previous Message Tom Lane 2001-05-18 19:20:47 Re: are NEW and OLD rule attributes broken?