pl/pgsql slowness - Mailing list pgsql-hackers

From Hannu Krosing
Subject pl/pgsql slowness
Date
Msg-id 3A192719.FC222BC8@tm.ee
Whole thread Raw
Responses Re: pl/pgsql slowness
List pgsql-hackers
Is it normal that a query that takes <1 sec when executed from psql
prompt 
takes >15 sek when executed from a function (and takes >95% of cpu for
all that time ?

example (on 7.0.2)

>UPDATE item SET id_path = '';

returns immediately (on 2000 item table)

then I create a function
CREATE FUNCTION "regenerate_id_paths" ( ) RETURNS int4 AS '   BEGIN       UPDATE item SET id_path = '''';       RETURN
-1;  END;
 
' LANGUAGE 'plpgsql';

and then

>select regenerate_id_paths( );

takes more than 15 sec and uses as much cpu as it can get while running;




BTW, where can I learn more about pl/pgsql süntax ?

The postgre docs suggest that "For more complex examples the programmer
might look at the regression
test for PL/pgSQL." but there is only one example using a for loop and
none using while. 

I suspect that it may be missing more.



-----------
Hannu


pgsql-hackers by date:

Previous
From: "Ivan E. Panchenko"
Date:
Subject: Indexing on arrays
Next
From: Larry Rosenman
Date:
Subject: err, XLOG/UW711/cc/Doesn't compile.