Thread: RAISE INFO in function

RAISE INFO in function

From
Yambu
Date:
Hi

May i know if RAISE INFO impacts performance significantly in a function?

Should i comment them out once i'm done using/debugging ?

regards

Re: RAISE INFO in function

From
Pavel Stehule
Date:


po 9. 11. 2020 v 14:46 odesílatel Yambu <hyambu@gmail.com> napsal:
Hi

May i know if RAISE INFO impacts performance significantly in a function?

Should i comment them out once i'm done using/debugging ?

It depends on more factors - but expressions in RAISE statements are calculated every time and sometimes the result can be filtered. Inside cycles or when functions is evaluated for every row of query, then the overhead can be significant:

postgres=# do $$
begin
  for i in 1..100000 loop
    raise debug '%', i;
  end loop;
end;
$$;
DO
Time: 35,164 ms
postgres=# do $$
begin
 -- plpgsql cannot to ignore empty blocks, this loop was evaluated 100K
  for i in 1..100000 loop
    --raise debug '%', i + 1;
  end loop;
end;
$$;
DO
Time: 2,535 ms

Regards

Pavel


regards