pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jie Liang <jliang@ipinc.com>
Cc: edipoelder@ig.com.br
Cc: pgsql-sql@postgresql.org
Subject: Re: using for rec inside a function: behavior very slow
Date: Mon, 02 Apr 2001 21:16:56 -0400
Message-ID: <24884.986260616@sss.pgh.pa.us> (raw)
In-Reply-To: <Pine.BSF.4.10.10104021504210.82239-100000@tidal.ipinc.com>
References: <Pine.BSF.4.10.10104021504210.82239-100000@tidal.ipinc.com>

Jie Liang <jliang@ipinc.com> writes:
>      v_url:= $1||''%'';                
>      for rec in select id,url from urlinfo where url like v_url order by
> url loop

[ is slow ]

LIKE index optimization doesn't happen if the LIKE pattern is a variable
when the plan is created.

In 7.1 you can work around this problem by using plpgsql's FOR ... EXECUTE
notation, but I don't think there's any good answer in 7.0.

for rec in execute ''select id,url from urlinfo where url like ''||quote_literal(v_url)||'' order by url'' loop

			regards, tom lane



view thread (2+ messages)

Message-ID: <24884.986260616@sss.pgh.pa.us>
Permalink:  ../24884.986260616@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/24884.986260616@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, jliang@ipinc.com, edipoelder@ig.com.br
  Subject: Re: using for rec inside a function: behavior very slow
  In-Reply-To: <24884.986260616@sss.pgh.pa.us>
  References: <Pine.BSF.4.10.10104021504210.82239-100000@tidal.ipinc.com> <24884.986260616@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