select statement inside a function: behavior bad - Mailing list pgsql-sql

From Jie Liang
Subject select statement inside a function: behavior bad
Date
Msg-id Pine.BSF.4.10.10104021657330.3774-100000@tidal.ipinc.com
Whole thread Raw
In response to Re: Fwd: Calling functions inside a function: behavior  (edipoelder@ig.com.br)
List pgsql-sql
I tested select statement inside sql and plpgsql function,
very slow


CREATE FUNCTION geturllike(text) RETURNS SETOF text AS '
SELECT url as url FROM urlinfo WHERE url LIKE $1;
'LANGUAGE 'sql';

CREATE FUNCTION hasdup(text) RETURNS int4 AS '
declare
   v_id         int4;
   rat1         text;
   rat2         text;
   v_url        text;
   rec          record;

begin
     v_url:= $1||''%'';

     for rec in select id,url from urlinfo where url like v_url order by
url loop
        raise notice ''%'',rec.url;
     end loop;
     return 0;
end;
' LANGUAGE 'plpgsql';

Why so slow????
Is it a bug??


Jie LIANG

St. Bernard Software

10350 Science Center Drive
Suite 100, San Diego, CA 92121
Office:(858)320-4873

jliang@ipinc.com
www.stbernard.com
www.ipinc.com



pgsql-sql by date:

Previous
From: Jie Liang
Date:
Subject: using for rec inside a function: behavior very slow
Next
From: Tom Lane
Date:
Subject: Re: using for rec inside a function: behavior very slow