Received: from postgresql.org.org (webmail.postgresql.org [216.126.85.28]) by postgresql.org (8.11.3/8.11.1) with SMTP id f4MEbOA87574 for ; Tue, 22 May 2001 10:37:24 -0400 (EDT) (envelope-from pgsql-sql-owner@postgresql.org) Received: from camay.yandex.ru (camay.yandex.ru [213.180.193.64]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f4J0XUA42549 for ; Fri, 18 May 2001 20:33:31 -0400 (EDT) (envelope-from aidanet@yandex.ru) Received: ("??"@camay.yandex.ru) by mail.yandex.ru id ; Sat, 19 May 2001 03:30:04 +0400 Subject: Why indexes are not used when scanning from functions? To: pgsql-sql@postgresql.org Date: Sat, 19 May 2001 03:30:04 +0400 (MSD) From: =?KOI8-R?B?IuzP19DB3sUg4crEwc3J0iI=?= Reply-To: =?KOI8-R?B?IuzP19DB3sUg4crEwc3J0iI=?= Message-Id: <3B05B07C.000001.06516@camay.yandex.ru> MIME-Version: 1.0 X-Mailer: Yamail [ http://yandex.ru ] Errors-To: =?KOI8-R?B?IuzP19DB3sUg4crEwc3J0iI=?= X-source-ip: 213.24.83.15 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Archive-Number: 200105/243 X-Sequence-Number: 3061 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