pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: "Ловпаче Айдамир" <aidanet@yandex.ru>
Cc: pgsql-sql@postgresql.org
Subject: Re: Why indexes are not used when scanning from functions?
Date: Wed, 23 May 2001 14:28:18 -0400
Message-ID: <16262.990642498@sss.pgh.pa.us> (raw)
In-Reply-To: <3B05B07C.000001.06516@camay.yandex.ru>
References: <3B05B07C.000001.06516@camay.yandex.ru>

=?KOI8-R?B?IuzP19DB3sUg4crEwc3J0iI=?= <aidanet@yandex.ru> writes:
> create function get_fio1(text) returns varchar
> as 'select fio from patient_temp where fio like $1::text || \'%\';'  
> language 'sql';

You won't get an indexscan for this because the LIKE pattern is not
a constant at planning time, and so the planner cannot extract indexscan
bounds from it.

In 7.1 it's possible to obtain the desired result in plpgsql, by using
EXECUTE.  You'd need to substitute the pattern into the query string
as a literal constant, not as a plpgsql variable.

			regards, tom lane



view thread (2+ messages)

Message-ID: <16262.990642498@sss.pgh.pa.us>
Permalink:  ../16262.990642498@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/16262.990642498@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, aidanet@yandex.ru
  Subject: Re: Why indexes are not used when scanning from functions?
  In-Reply-To: <16262.990642498@sss.pgh.pa.us>

* 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