pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: "Ловпаче Айдамир" <aidanet@yandex.ru>
To: pgsql-sql@postgresql.org
Subject: Why indexes are not used when scanning from functions?
Date: Sat, 19 May 2001 03:30:04 +0400 (MSD)
Message-ID: <3B05B07C.000001.06516@camay.yandex.ru> (raw)

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@yandex.ru>





view thread (2+ messages)  latest in thread

Message-ID: <3B05B07C.000001.06516@camay.yandex.ru>
Permalink:  ../3B05B07C.000001.06516@camay.yandex.ru/
Also on:    postgresql.org/message-id/3B05B07C.000001.06516@camay.yandex.ru

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: aidanet@yandex.ru
  Subject: Re: Why indexes are not used when scanning from functions?
  In-Reply-To: <3B05B07C.000001.06516@camay.yandex.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox