Hi,
It seems postgres cache the plan under CacheMemoryContext during the
plpgsql executing.
If there is a function with lots of variables and every one of them got a
default value,
postgres will allocate lots of memory for caching the default value plan(we
have to run
the function at least once). Once we DROP the function, the memory consumed
by the plan
will be leak. The same thing for the compiled function
structure(PLpgSQL_function).
Is this an oldest known question?
Thanks,
Tao Ma