Hi,
I'm trying to time a pl/sql function using a rougn and ready method,
basically: print a TIMESTAMP at the begining of the function, print a
TIMESTAMP at the end of the function.
So...:
CREATE OR REPLACE FUNCTION timer() RETURNS INTEGER AS '
DECLARE
timer1 TIMESTAMP;timer2 TIMESTAMP;num_operators INTEGER;
BEGINtimer1 := ''now''; -- As suggested in 23.4 of programmer guide RAISE NOTICE ''Start: %'', timer1;/* Some
functionwhich takes time.Here, a select from a pg catalogue */ SELECT INTO num_operators COUNT(*) FROM
pg_operator;timer2:= ''now'';RAISE NOTICE ''End: %'', timer2;RETURN(num_operators);
END;'
LANGUAGE 'plpgsql';
Gives me:
testdb2=# select timer();
NOTICE: Start: 2002-11-26 13:40:14.116605+00
NOTICE: End: 2002-11-26 13:40:14.116605+00timer
------- 623
(1 row)
I've tried all sorts of variations but I hit one of two problems; either the
TIMESTAMP is fixed to the function compile time or, as above, the timer1 and
timer2 TIMESTAMPs are always identical.
Any help/pointers/suggestions appreciate... well of course a working
solution would be the best ;)
Cheers,
Stuart.