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

Reply via email to