CREATE or replace PROCEDURE t_now(num integer)
AS
DECLARE
n numeric :=0;
curtime timestamp;
BEGIN
LOOP
n := n + 1;
curtime := now();
EXIT WHEN n > num;
END LOOP;
END;
/
before optimization:
openGauss=# call t_now(1000000);
t_now
-------
(1 row)
Time: 4714.785 ms
after optimization:
openGauss=# call t_now(1000000);
t_now
-------
(1 row)
Time: 4575.570 ms